how to think like a computer scientist ch. 2 questions
data-9-1: What is the value of the following expression: 16 - 2 * 5 // 3 + 1
A. 14
data-7-1: What value is printed when the following statement executes? print(18 / 4)
A. 4.5
data-9-2: What is the value of the following expression: 2 ** 2 ** 3 * 3
A. 768
data-8-1: What is printed when the following statements execute? n = input("Please enter your age: ") # user types in 18 print ( type(n) )
A. <class 'str'>
data-3-1: What value is printed when the following statement executes? print( int(53.785) )
B. 53
data-5-1: True or False: the following is a legal variable name in Python: A_good_grade_is_A+
B. False
data-2-1: How can you determine the type of a variable?
B. Use the type function.
data-11-1: What is printed when the following statements execute? x = 12 x = x - 1 print(x)
C. 11
data-11-2: What is printed when the following statements execute? x = 12 x = x - 3 x = x + 5 x = x + 1 print(x)
C. 15
data-7-2: What value is printed when the following statement executes? print(18 // 4)
C. 4
data-4-1: What is printed when the following statements execute? day = "Thursday" day = 32.5 day = 19 print(day)
D. 19
data-7-3: What value is printed when the following statement executes? print(18 % 4)
D. 2
data-2-2: What is the data type of 'this is what kind of data'?
D. String
data-10-1: After the following statements, what are the values of x and y? x = 15 y = x x = 22
D. x is 22 and y is 15
data-8-2: Click on all of the variables of type `int` in the code below seconds = input("Please enter the number of seconds you wish to convert") hours = int(seconds) // 3600 total_secs = int(seconds) secs_still_remaining = total_secs % 3600 print(secs_still_remaining)
hours, total_secs, secs_still_remaining
data-8-3: Click on all of the variables of type `str` in the code below seconds = input("Please enter the number of seconds you wish to convert") hours = int(seconds) // 3600 total_secs = int(seconds) secs_still_remaining = total_secs % 3600 print(secs_still_remaining)
seconds