Python Part 1 of 4 parts - Unit 1
If book_title = "The Xylophone Case" which code will return True?
"x" in book_title
Which is a valid Python code comment?
# use comments to describe the function of code.
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 version of Python does this course cover?
Python 3
This is a true statements about Python
Python variables are case sensitive
What is the output of the following code? print("She said, \"Who's there?\"")
She said, "Who's there?"
Which is not a way to run a code cell in a Jupyter Notebook?
Shift + R
Which of the following is a valid Python comment structure?
Which of the following is a valid Python comment structure?
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() and "upper".islower()
In Python, strings can contain only letters a-z and A-Z.
False
For the code x >= y which x and y values evaluate True?
For the code x >= y which x and y values evaluate True?
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
Jupyter Notebooks have code cells and markdown cells.
True
What are the advantages of creating and using functions in code?
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 "Chapter1"?
s = "Chapter" + str(1)
Which is not a possible "infinity/infinite" loop?
while 0 > 1: