Fundamentals of Computer Science I (CSC-151.02 2000F)

Booleans, Numbers, and Other Basic Types

You may want to refer to the reading on Boolean values and predicates and the reading on numbers before or while you work on this lab.


Exercise 0: Preparation

a. If you haven't done so already, you may wish to skim the readings.

b. Start DrScheme.

Exercise 1: Type Predicates

Fill in the following table (or as much as you think is appropriate)

5 5.0 'five "five" list #t #f (cons 'a null) null 'null ()

Exercise 2: Empty lists

Which of the following does Scheme consider an empty list?

Exercise 3: Equality

Consider the following definitions

(define alpha (list 'a 'b 'c))
(define beta (list 'a 'b 'c))
(define gamma alpha)

Determine which of the lists are eq?, eqv?, or equal?.

Exercise 4: Reflection

Did you see anything surprising in the previous exercises?

Exercise 5: What is not?

a. What type is not?

b. What predicate would you use to verify your answer?

Exercise 6: What is not? Revisited

The symbol not is the name of something, as you determined in the preceding exercise. However, the symbol itself, considered as a datum, is not a procedure. Does Scheme agree with this classification? How could one ask Scheme whether the symbol not is a procedure?

Exercise 7: Combining Boolean Values

Fill in the following tables for each of the operations and and or.


First argument Second argument Result
#f #f  
#f #t  
#t #f  
#t #t  


First argument Second argument Result
#f #f  
#f #t  
#t #f  
#t #t  

Exercise 8: Ranges

a. Write a Boolean expression that determines if the value named by grade is between 0 and 100, inclusive.

b. Test that expression using different values of grade.

Exercise 9: Types of Numbers

Have DrScheme confirm that 3/4 is a rational number but not an integer and that the square root of -1 is a complex number but not a real number.

Exercise 10: The Type of a Square Root

Confirm that the value DrScheme computes for (sqrt 2) is an inexact real that is also rational.

Exercise 11: More Types of Numbers

As you've just seen, some kinds of numbers are subsets of other kinds of numbers. Determine the relationships between the various kinds of numbers.

Exercise 12: A Large Number

Write a Scheme numeral for 1.507 times ten to the fifteenth power, as an exact number. Have Scheme evaluate the numeral.

Exercise 13: Inexact Roots

a. Have DrScheme find the square of the square root of 2 and subtract 2 from the result.

b. Ideally, the difference should be 0; why isn't it?

c. How big is the difference?

d. Will you have the same problem if you start with 4? Why or why not?

Exercise 14: Inexact Fractions

Write a Scheme numeral for one-third, as an inexact number. Have Scheme evaluate the numeral.


Today's lab currently lacks notes.


Monday, 4 September 2000 (Sam Rebelsky)

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at

Source text last modified Wed Sep 13 10:50:27 2000.

This page generated on Fri Sep 15 10:15:11 2000 by Siteweaver. Validate this page's HTML.

Contact our webmaster at