What will this code print?
print("Hello\nWorld")
Hello
World
What symbol is used in Python to assign a value to a variable?
Equal sign =
Called an "assignment operator"
What is a list in Python?
A collection of items stored in one variable
This type of loop repeats a set of instructions for each item in a list
What is a for loop
This statement checks a condition and executes a block of code only if the condition evaluates to True.
What is an if statement
How do you add a tab space in a Python string?
Use \t inside the string
What data type would the value 42 be in Python?
Integer
whole number - positive or negative
What index does Python start counting from in a list?
what is 0
In the below loop, what is magician?
for magician in magicians:
A variable that stores each item of the list one at a time
Which operator is used to check if two values are equal?
What is ==
What does the print() function do?
Shows text or values on the screen
The number 3.14 would be what dat type?
float
decimal number
Which method adds a new item to the end of a list?
What is append()
In Python, this formatting is required to show which lines of code belong to a loop, function, or conditional block.
What is indention
Which keyword should you use when there are more than two choices in your logic?
What is elif
Stands for: else if
What does the \n character do in a string?
Moves text to a new line
Which is a valid variable name?
student_age
2students
student-age
student age
student_age
2students- can't start with a number
stundent-age - dashes are a no
student age - cannot have spaces
In a list, to store several items together and access them by index, you enclose them in this kind of brackets, separated by what?.
Use square brackets [ ] with items separated by commas
What will this code print?
magicians = ['alice', 'david']
for magician in magicians:
print(magician)
print("Done")
alice, david, then Done
Which logical operator requires all conditions to be True?
What is and
What is the name of the string formatting method that allows you to embed variables directly inside a string using curly braces {}
What is f-string
Which method turns text uppercase?
.upper()
Which function shows a sorted version of a list without changing the original?
What is sorted()
How do you access the last item of a list?
What is list[-1]
Since the input() function always returns a string, you must do this to the data before performing math operations.
What is convert