CNIT 155 MIDTERM QUESTIONS & ANSWERS
The int function can be used to convert a string of digits into an integer. - Answers -
True
Any inputted data is considered string data, regardless of what the user inputted. -
Answers -True
Computers can create true random numbers - Answers -False
Boolean only has two possible values. - Answers -True
The if-else structure will always execute only one of the two actions. - Answers -True
What is the extension of the source file for a python program - Answers -.py
A logical operator determines whether a specific relationship exists between two values
- Answers -False
Which of the following correctly define string variable in python?
ProgrammerDialogue = 'Coding in python is fun!'
CNIT = *I am a CIT student.*
PurdueString = I attend Purdue University.
All of the above - Answers -ProgrammerDialogue = 'Coding in python is fun!'
IF is a legal python identifier - Answers -False
String can be used as a sequence in a for loop - Answers -True
Python needs a main function to operate - Answers -False
While loops are pretest loops - Answers -True
Syntax Errors occur when a program provides you with actual outputs that are different
from the desired outputs (The program runs but it gives the wrong results). - Answers -
False
sum_total is a legal python identifier - Answers -True
IN is a reserved word in Python - Answers -True
It is better to use elif over else to cover all the remaining cases in a chained if/elif. -
Answers -False
, The input function returns a Boolean if the user types in True - Answers -False
The expression (2 + * 3) results in an integer value - Answers -False
The ^ operator is the same as the ** operator in Python - Answers -False
In Python, the division operator (/) gives a float result, even if both of the numbers are
integers - Answers -True
If you enter a bunch of letters in response to the input function, the input function returns
a string. - Answers -True
What is the output of the following code?
n = 20
while (n <= 25):
print (n,"\n")
n = n + 1 - Answers -20, 21, 22, 23, 24, 25
The expression 3 ** 3 - ( 6 - 2 ) / 2 has the value _____. Is it an integer or a float value?
__________________.
7, int
25, float
7, float
25, int - Answers -25, float
What is max(3, 5, 1, 7, 4)? - Answers -7
What is printed by the last line of the following code:
x = 10
y = input("enter a letter: ")
print(y)
Assume the user enters the letter z in response to the prompt - Answers -z
What is printed by the last line of the following code:
x = 10
y = input("enter a letter: ")
print(y)
Assume the user enters the letter x in response to the prompt - Answers -nothing, an
error occurs
The int function can be used to convert a string of digits into an integer. - Answers -
True
Any inputted data is considered string data, regardless of what the user inputted. -
Answers -True
Computers can create true random numbers - Answers -False
Boolean only has two possible values. - Answers -True
The if-else structure will always execute only one of the two actions. - Answers -True
What is the extension of the source file for a python program - Answers -.py
A logical operator determines whether a specific relationship exists between two values
- Answers -False
Which of the following correctly define string variable in python?
ProgrammerDialogue = 'Coding in python is fun!'
CNIT = *I am a CIT student.*
PurdueString = I attend Purdue University.
All of the above - Answers -ProgrammerDialogue = 'Coding in python is fun!'
IF is a legal python identifier - Answers -False
String can be used as a sequence in a for loop - Answers -True
Python needs a main function to operate - Answers -False
While loops are pretest loops - Answers -True
Syntax Errors occur when a program provides you with actual outputs that are different
from the desired outputs (The program runs but it gives the wrong results). - Answers -
False
sum_total is a legal python identifier - Answers -True
IN is a reserved word in Python - Answers -True
It is better to use elif over else to cover all the remaining cases in a chained if/elif. -
Answers -False
, The input function returns a Boolean if the user types in True - Answers -False
The expression (2 + * 3) results in an integer value - Answers -False
The ^ operator is the same as the ** operator in Python - Answers -False
In Python, the division operator (/) gives a float result, even if both of the numbers are
integers - Answers -True
If you enter a bunch of letters in response to the input function, the input function returns
a string. - Answers -True
What is the output of the following code?
n = 20
while (n <= 25):
print (n,"\n")
n = n + 1 - Answers -20, 21, 22, 23, 24, 25
The expression 3 ** 3 - ( 6 - 2 ) / 2 has the value _____. Is it an integer or a float value?
__________________.
7, int
25, float
7, float
25, int - Answers -25, float
What is max(3, 5, 1, 7, 4)? - Answers -7
What is printed by the last line of the following code:
x = 10
y = input("enter a letter: ")
print(y)
Assume the user enters the letter z in response to the prompt - Answers -z
What is printed by the last line of the following code:
x = 10
y = input("enter a letter: ")
print(y)
Assume the user enters the letter x in response to the prompt - Answers -nothing, an
error occurs