Cmpsc 101 midterm Exam #1 Questions with Correct Answers
The Range(1,10,3) produces the values
A. 1,4,7,10
B. 1,4,7
C. 1,3,5,7,9
D. 1,10,3 - ✔✔B. 1,4,7
How many asterisks would be printed by these two code fragments?
A. 12 in both cases
B. 6 in both cases
C. 12 in the one on the left; 6 in the one of the right
D. 6 in the one on the left; 4 in the one on the right - ✔✔C. 12 in the one on the
left; 6 in the one of the right
If is_prime is a function that identifies whether its argument was prime, what
would this short function return?
A. The value 2 only
B. The value 7 only
C. All of the small primes in a list: [2,3,5,7]
D. One small prime, and a different one each time it is called. - ✔✔A. The value 2
only
The Range(1,10,3) produces the values
A. 1,4,7,10
B. 1,4,7
C. 1,3,5,7,9
D. 1,10,3 - ✔✔B. 1,4,7
How many asterisks would be printed by these two code fragments?
A. 12 in both cases
B. 6 in both cases
C. 12 in the one on the left; 6 in the one of the right
D. 6 in the one on the left; 4 in the one on the right - ✔✔C. 12 in the one on the
left; 6 in the one of the right
If is_prime is a function that identifies whether its argument was prime, what
would this short function return?
A. The value 2 only
B. The value 7 only
C. All of the small primes in a list: [2,3,5,7]
D. One small prime, and a different one each time it is called. - ✔✔A. The value 2
only