Comp110 Exam Questions With Correct
Answers A+
Comparing two string values using relational operators always works the way you would expect
it to in the English language. T/F? - Answer✔False
Which operator is used for integer division and results in an int typed value?
Choice 1 of 4:/Choice 2 of 4://Choice 3 of 4:%Choice 4 of 4:div - Answer✔Choice 2: //
The random package has many functions for generating random numbers. There's a random
function defined in the random package, you can import and call using a function call expression
like so:
>>> from random import
random >>> random()
Try calling the random function many times. What type does a call to the random function
evaluate to?
Choice 1 of 3:<class 'str'>Choice 2 of 3:<class 'float'>Choice 3 of 3:<class 'int'> -
Answer✔Choice 2: <class 'float'>
The following statement CANNOT be a valid line of code in a program because it is illogical:
age = age + 1
Choice 1 of 2:TrueChoice 2 of 2:False - Answer✔False
Consider the following expression:
True and False or False and not False
Which operator evaluates first?
Choice 1 of 3:andChoice 2 of 3:notChoice 3 of 3:or - Answer✔not
Consider the following expression:
True and False or False and not False
Which operator evaluates last?
Choice 1 of 3:andChoice 2 of 3:notChoice 3 of 3:or - Answer✔or