Font size
WorksheetsPython Domain
Total questions: 20
Worksheet time: 10mins
Given the following string:
h = "Hello", which code results in an error?
print (h)
print(h.lower())
h = 's'
print(h+1)
What is the output of the following code?
Good Bye
Welcome
An error message
None of the above
What does the input() function return?
an integer value
a string value
a float value
all of the above
What is the value of x after the following code is run?
19
20
21
22
Which statements evaluate True and without errors?
"unbothered".isupper()
"Monroe High School".istitle()
5.isdigit()
"animal".islower()
Which statement sets the variable t to a value of "Total Credits: 25"?
t = "Total Credits:" + 25
t = "Total Credits:" + str(25)
t = input("Total Credits:" + str(25))
print("Total Credits", "25")
What is "print" used for?
To input
To make strings
To display output
Non of the above
What is the output of the following code?
print("He said, \"I'm coming to school tomorrow.\"")
"He said, I'm coming to school tomorrow."
'He said, "I'm coming to school tomorrow."'
He said, \I'm coming to school tomorrow.\
He said, "I'm coming to school tomorrow."
Which operator can be used to combine two strings?
+
-
!
/
If book_title = "Gone with the Wind" which code will return True
"G" in book_title
book_title.startswith("g")
print("g", book_title)
book.title.has("g"
What are the advantages of creating and using functions in code? (Choose all that apply)
code reuse
Boolean string testing
faster running code
easier testing
Which is a python function?
input()
"Hello Students"
x = 4
def
Analyze the following code and choose the most correct statement:
The program runs and displays "It is even!"
The program runs, but displays nothing.
The program has a Syntax Error in line 1: even = false
The program has an error in line 2: if Even == True
Which of the following is a valid Python comment structure?
#comment
- comment
/*comment*/
/#comment#/
For the code x>= y which x and y values evaluate True?
x = 5, y = 6
x = "b", y = "B"
x = 0, y = 1
x = "Z", y = "a"
Which is a Python method of getting numeric input that can be used in math?
num1 = get_int
num1 = str(input("enter a number"))
num1= (input("enter a number")).float()
num1 = int(input("enter a number"))
Which is not a possible "infinity/infinite" loop?
while True:
while 1 > 0:
while 1 != 0:
while 0 >1:
Which of the following statement is true?
Python variables are case sensitive
Python variables have a fixed, unchangeable data type
Python variable names start with a number, letter or underscore
All the above
What will be displayed by the following code?
Hello Hello Hello Hello
Hello Hello Hello Hello Hello Hello Hello Hello
Hello Hello Hello Hello Hello Hello Hello
Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello
What is the order of precedence (from first to last ) of the math operators?
+, -,/,*
*,+,-,/
*,/,+,-
*,+,/,-
