Python Basics
Lists and Tuples
Functions
Classes and Objects
What's Wrong With This Code?
100

What are the four most common data types?

String, Int, Boolean, Float

100

What’s the difference between a list and a tuple?

Lists are mutable, tuples are not.

100

What keyword starts a function definition in Python?

"def"

100

What is the purpose of the init() function in a class?

Initializes new object and its attributes.

100

my_list = [1, 2, 3]; my_list.pop(3)

Index 3 out of range (valid 0–2).

200

What keyword is used to check a condition?

"if"

200

Write a list with three fruits

["apple", "banana", "cherry"]

200

What is a parameter?

A variable used inside a function to accept input

200

In this line, which is the class and which is the object? player1 = Gamer("Alex")

Gamer is class; player1 is object.

200

print("My age is " + 15)

Can't concatenate str and int.

300

What does this return?
5 > 2 and 3 < 1

False

300

How do you access the first element in a list called items?

items[0]

300

What will this function return?
def mystery(x):
if x % 2 == 0: return x // 2
else: return x * 3
mystery(4)

2

300

What does this print?
class Cat:
def __init__(self, name): self.name = name
c = Cat("Luna")
print(c.name)

"Luna"

300

numbers = [1, 2, 3]
numbers.append = 4

You’re trying to assign a value to append, which is a built-in method.

400

Name 3 boolean comparison operators

==, !=, >=, <, <=, >

400

What does this code print?
nums = [1, 2, 3]
nums[1] = 5
print(nums)

[1, 5, 3]

400

What does this code print and why?
def f(x): x += 1
return x
y = 5
f(y)
print(y)

5 (integers are immutable; x is a copy) 

400

Write a method inside a class that returns the square of an attribute called side.

def area(self):
return self.side ** 2

400

x = input("Enter a number: ")
if x > 10:
    print("Big number!")

input() returns a string, so comparing it to an integer causes an error.

500

What built-in function do you use to get the data type of a variable?

type()

500

DAILY DOUBLE: What will this print?
nums = [10, 20, 30]
nums.insert(1, 15)
nums.pop()
print(nums)

[10, 15, 20]
Inserts 15 at index 1 -- in between 10 and 20.
pop() will remove the last element(30)

500

What does this return?
def func(x):
if x > 0: return x + func(x - 1)
else: return 0
print(func(2))

3 --- (2+1+0)

500

Create a class Rectangle that stores width and height and has a method area() returning the area.

class Rectangle:
self.width = width
self.height = height
def area(self): return self.width * self.height

500

count = 0
def increase():
    count += 1
    print(count)
increase()

count cannot be accessed within the function, it has not been defined locally.
use global count to do so 

M
e
n
u