Basic Functions
Variables & Operators
Data Types
Casting & Concatenation
Control Flow
100

How do you print the statement: Hello World

print(Hello World)

100

Create a variable x and set it to the string: "test"

x = "test"

100

What is an example of a string?

"hi"

100

Cast the integer: 42 to a string

str(42)

100

What 2 values can a boolean return?

True, False

200
How do you set a variable to an input?

x = input("enter x: ")

200

print the sum of 3 and 5

print(3+5)

200

What is an example of an integer?

21

200

Put together separate strings "Hello " and "World" to make one message.

message = "Hello " + "World

200

Write an if statement comparing 2 and 3.

if 2 == 3:

300

How do you create a function?

function():
300

set variables to 9 and 4 and find the difference

num1 = 9

num2 = 4

difference = num1 - num2

300

What is the difference between an integer and a float?

Integer must be whole. Float can include decimals.

300

Turn the integer "36" into a string.

str("36")

300

What does an else statement do?

The else statement is executed in the case that the if condition is false.

400

Create a function that gets the user's name and prints it back to them.

function():

  name = input("what is your name?")

  print(name)

400

what does the operator: // mean?

Floor Division, returns the largest possible integer


400

Give an example of a boolean.

number1 == number2

400

Get the user's name and return: hi user_name

print("hi " + input("what's your name? "))

400

What are Python's 3 default Boolean Operators?

and (only returns true for Boolean if both are true)

or (returns true for Boolean if either of the arguments are true)

not (inverts modifying argument)

500
Create a function that gets 2 integers from the user and adds them together.

function():

  number1 = input("enter first number: ")

  number2 = input("enter second number: ")

  print(int(number1) + int(number2))

500

Create 3 integer variables and find the mean of them.

x = 1

y = 2

z = 3

mean = float(x + y + z) / float(3)

500
Why does this line of code not work?

sum = input() + 8

input() returns a string, which cannot be added with an integer. You must first cast it using int().

500

Get the user's age and return: you will be - in 4 years.

print("you will be " + str(int(input("age: ")) + 4) + " in 4 years")

500

Ask the user for a number, if it is equal to 7, then return correct, but if not, return incorrect.

number = input("number: ")

if number == 7:

  print("correct")

else:

  print("incorrect")

M
e
n
u