Python Programming Final Unit 1a Test
If book_title = "The Xylophone Case" which code will return True?
"x" in book_title
Which of the following is a valid Python comment structure?
# comment
What is the order of precedence (from first to last) of the math operators?
*, /, +, -
Which operator can be used to combine two strings?
+
What is the value of x after the following code is run? x = 2 y = 1 x += y + 1
4
Which of the following statements is true?
Python variables are case sensitive
What is the output of the following code? print("She said, \"Who's there?\"")
She said, "Who's there?"
What does the input() function return?
a string value
What is the output of the following code? name = 123 if name.startswith("a"): print("welcome") else: print("please wait")
an error message
Which is a Python method of getting numeric input that can be used in math?
num1 = int(input("enter a number"))
Which of the following is a Python function?
print()
What will be displayed by the following code? count = 0 while count < 5: print("Hello", end = " ") count +=1
Hello Hello Hello Hello Hello
Which statements evaluate True and without errors?
"The Title".istitle(), "upper".islower()
Analyze the following code and choose the most correct statement: even = False if even = True: print("It is even!")
The program has a SyntaxError in line 2: if even = True:
What is "print" used for?
To display output
What are the advantages of creating and using functions in code?
code reuse and easier testing
Given the following string: s = "Welcome" which code results in an error?
print(s + 1)
Which statement sets the variable s to a value of "Chapter 1"?
s = "Chapter" + str(1)
Which is not a possible "infinity/infinite" loop?
while 0 > 1:
For the code x >= y which x and y values evaluate True?
x = "a", y = "A"