How do you start a comment in Python?
#
What is the result of 5 == 5?
True
How do you check if x is equal to y in Python?
if x==y:
What method adds an element to the end of a list?
append()
What brackets does the syntax start with?
squiggly brackets
What function prompts the user to type data manually?
input()
What is the operator for exponentiation in Python?
**
What will be the output of the following code?
x is greater than 2
How do you access the first element of a list named my_list?
my_list[0]
How do you add a key-value pair ('age', 30) to a dictionary my_dict
my_dict['age'] = 30
What is the output of print(type(10))?
<class 'int'>
What is the result of 10 % 3
1
What does the else keyword do in a Python conditional statement?
he else keyword provides a block of code to execute when the if condition is False.
What method removes the last item of a list?
pop()
How do you access the value associated with the key 'age' in a dictionary my_dict
my_dict['age']
What is the difference between = and == in Python?
= is the assignment operator, while == is the equality operator
What does the // operator do
Floor division
How do you check if a string name is not equal to "Bob" in Python?
if name != "Bob":
How do you access the last element of a list named my_list?
my_list[-1]
How do you check if the key 'name' exists in a dictionary my_dict?
'name' in my_dict
What is the difference between 10 and "10" in Python?
10 is an integer, whereas "10" is a string.
What is the result of the following expression and explain why: 3 + 4 * 2 // (1 - 5) ** 2?
3
How do you check if a list my_list is empty in Python?
if len(my_list) == 0:
Describe how you would access the third element in a list my_list and what happens if the list has less than three elements.
o access the third element in my_list, you would use my_list[2] (indexing starts at 0). If the list has fewer than three elements, trying to access my_list[2] will raise an IndexError.
What method would you use to get all the values in a dictionary my_dict
my_dict.values()