Python Basics
Operations
Conditional
Lists
Dictionary
100

How do you start a comment in Python?

#

100

What is the result of 5 == 5?

True

100

How do you check if x is equal to y in Python?

if x==y:


100

What method adds an element to the end of a list?

append()

100

What brackets does the syntax start with?

squiggly brackets 

200

What function prompts the user to type data manually?

input()

200

 What is the operator for exponentiation in Python?


**

200

 What will be the output of the following code?

x = 5
if x > 2:    
     print("x is greater than 2")
else:   
    print("x is not greater than 2")


x is greater than 2

200

 How do you access the first element of a list named my_list?

my_list[0]

200

How do you add a key-value pair ('age', 30) to a dictionary my_dict

my_dict['age'] = 30

300

What is the output of print(type(10))?


<class 'int'>

300

What is the result of 10 % 3

1

300

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.

300

What method removes the last item of a list?

pop()

300

How do you access the value associated with the key 'age' in a dictionary my_dict

my_dict['age']

400

What is the difference between = and == in Python?

= is the assignment operator, while == is the equality operator

400

What does the // operator do

Floor division

400

How do you check if a string name is not equal to "Bob" in Python?

if name != "Bob":

400

How do you access the last element of a list named my_list?

my_list[-1]

400

How do you check if the key 'name' exists in a dictionary my_dict?

'name' in my_dict

500

What is the difference between 10 and "10" in Python?

10 is an integer, whereas "10" is a string.

500

What is the result of the following expression and explain why: 3 + 4 * 2 // (1 - 5) ** 2?

3

500

How do you check if a list my_list is empty in Python?

if len(my_list) == 0:

500

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.

500

What method would you use to get all the values in a dictionary my_dict

my_dict.values()

M
e
n
u