What data type uses quotation marks around it?
String
How do you properly print the following using one line of code: Hello World!
print("Hello World!")
What does elif mean and when is it used?
elif = else if
Used as a part of an if statement
What is the command used to create a function?
def
Create a list of three numbers with one line of code.
list1 = [1, 2, 3]
Which variable type can store decimals?
Floats
How do you take a number as input and store it as an integer using one line of code? You may put anything you want as the parameter to the input command provided it is the correct data type.
example = int(input("Enter a number: "))
while True: will create an infinite loop
Also, any condition that never becomes false will also be an infinite loop
How can I call the following function with 5 and 7 as my inputs, respectively?
def mystery_function(num1: int, num2: int):
# some code here
mystery_function(5, 7)
What statement must you always have at the start of any program that uses the random package and any of its functions?
import random
Name the five data types discussed in this class.
Create a single line of code that will:
1. Prompt the user for their age. You may assume it will be under 18.
2. Print the following: You have ___ years left until you can vote!
print("You have", 18 - int(input("Enter your age: ")), "years until you can vote!")
What data type is the condition of a while loop?
Ex. while x > 5:
# some code here
Boolean
Create a line of code that defines a function with 5 parameters: 1 must be a float, 1 must be a String, 2 must be integers, and 1 must be a Boolean.
def some_function(param1: float, param2: str, param3: int, param4: int, param5: bool)
Write one line of code that prints the square of a randomly generated number between 1 and 10.
print(random.randint(1, 10)**2)