Question 1
True and False are Boolean keywords in Python
True
False
Question 2
0.0/1.0 point (graded)
hot_plate = True
if hot_plate:
print("Be careful, hot plate!")
else:
print("The plate is ready.")
The output of from running the above code is ___
"Be careful, hot plate!"
"The plate is ready."
"True"
NameError
Question 3
0.0/1.0 point (graded)
vehicle_type = "Truck"
if vehicle_type.upper().startswith("P"):
print(vehicle_type, 'starts with "P"')
else:
print(vehicle_type, 'does not start with "P"')
The output of from running the above code is ___
"Truck starts with "P""
"Truck does not start with "P""
"True"
"False"
Question 4
0.0/1.0 point (graded)
year = "2001"
if year.isdigit():
print(year, "is all digits")
else:
pass
The output of from running the above code is ___
"True"
"False"
No Output
"2001 is all digits"
Question 5
The double equal sign (==) is used to compare values
True
False
Question 6
Given x = 9 which line of code will evaluate False?
x == 9
x < 3
3 < x
x = 3
Question 7
assignment = 25
if assignment = 25:
print('use "=" to assign values')
else:
pass
The output of the above code is ___
SyntaxError
"use "=" to assign values"
True
No Output
Question 8
0.0/1.0 point (graded)
id = 3556
if id > 2999:
print(id, "is a new student")
else:
print(id, "is an existing student")
The output of the above line of code is ___
"id, is a new student"
"3556 is a new student"
"id, is an existing student"
"3556 is an existing student"
Question 9
In Python string comparisons, lower case "a" is less than upper case "A"
True
False
Question 10
name = "Tobias"
print(name == "Alton")
The output of from running the above code is ___
"Tobias = Alton"
"Alton"
True
False
Question 11
day = "monday"
if day.capitalize() == "Monday":
print("Start the week!")
else:
pass
The output of from running the above code is ___
True
False
No output
"Start the week!"
Question 12
name = "Jin Xu"
if type(name) == type("Hello"):
print(name, "is a string entry")
else:
print(name, "is not a string entry")
The output of the above line of code is ___
"Hello Jin Xu"
"Jin Xu is a not string entry"
"Jin Xu is a string entry"
"string"
ALL QUESTIONS CODE ARE RELATED TO Python 3 , and should be SOLVED on Python 3.
Question 1
It is true.
True and False are Boolean keywords in Python.
Question 2
The first option is the correct answer.
The program output will be "Be careful, hot plate!".
Question 3
The second option is the correct answer.
The program output will be "Truck does not start with "P"".
Question 4
The fourth option is the correct answer.
The program output will be "2001 is all digits".
Question 5
It is true.
'==' in python is known as the equality or comparison operator.
Question 6
The second option is the correct answer.
Given x = 9 the line x<3 will be false.
Question 7
The first option is the correct answer.
The program output will show Syntax Error. This is because of '=' or assignment operator is used instead of '==' or comparison operator.
Question 8
The second option is the correct answer.
The program output will be "3556 is a new student".
Question 9
It is false.
In Python string comparisons, lower case "a" is greater than upper case "A".
Question 10
The fourth option is the correct answer.
Since comparison operator is being used here so it will return false as Tobias is not equal to Alton.
Question 11
The fourth option is the correct answer.
The program output will be "Start the week!".
Question 12
The second option is the correct answer.
The program output will be "Jin Xu is a not string entry".
Hope this helps.
Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point...
1) Which of the following is NOT true about a Python variable? a) A Python variable must have a value b) A Python variable can be deleted c) The lifetime of a Python variable is the whole duration of a program execution. d) A Python variable can have the value None. 2) Given the code segment: What is the result of executing the code segment? a) Syntax error b) Runtime error c) No error d) Logic error 3) What...
For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of A2 Student class demo ') s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0) s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints...
Python Programming assignment : Function of Q3: def isPositive(n): if(n>=0): return True else: return False Write a code for function main, that does the following: -creates a variable and assigns it the value True. - uses a while loop which runs as long as the variable of the previous step is True, to get a number from the user and if passing that number to the function of Q3 results in a True value returned, then add that number to...
Python Programming assignment : Function of Q3: def isPositive(n): if(n>=0): return True else: return False Write a code for function main, that does the following: -creates a variable and assigns it the value True. - uses a while loop which runs as long as the variable of the previous step is True, to get a number from the user and if passing that number to the function of Q3 results in a True value returned, then add that number to...
Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...
Question 2 1 point possble (graded) Consider the following code segment. String a- a0 if (a-0") else if (a"1") else if (a" else( System.out.printin("a is 0 System.out.printin("a is 1! System.out.println("a is al") System.out.println(a is something else!) Which of the following statements about the code segment is true? It produced "a is 0!" as output It produced "a is 1!" as output It produced "a is a!" as output It produced "a is something else!" as output It results in an...
IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is a list of non-empty strings. If each string in the list starts with a capital letter, then the function should return the value True. If some string in the list does not start with a capital letter, then the function should return the value False You may use any of the string functions that are available in Python in your solution, so you might...
Must be in Python 3 exercise_2.py # Define the Student class class Student(): # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...
QUESTION 21 while True: , in Python, can be used to create an infinite loop. True False 2 points QUESTION 22 The Python Framework does inform you where an error occurred True False 2 points QUESTION 23 ____ is a critical component to being able to store data and information long term. File Access Memory Print function with 2 points QUESTION 24 Error handling is also known as ___ handling Result Recursion Exception Crash 2 points ...