A value that can be stored by a variable name and referenced later
What is a list in Python
an ordered collection of items
What keyword is used to create a basic if statement in Python
if
How do you check if a value or variable is equal to another
==
State at least three math operators in Python
+ , - , / , * , ** , %... etc
What is an if statement
It checks if something is true. if it is, it runs what is inside
How do you access the first element of a list named my_list
my_list[0]
ow do you write an if statement that checks if a number x is greater than 10?
if x > 10:
What is the correct way to print "Hello, World!" in Python?
print("Hello, World!")
What is the purpose of input() in Python?
to receive input from the user
What is a function?
a reusable block of code that performs a specific task
What are stored inside lists?
Elements
if 5 > 10:
print("Yes")
else:
print("No")
what will this return?
No
How do you define a variable called my_var with the value 10?
my_var = 10
What does the len() function do?
it returns the number of elements in an object (like a list or string)
What is the formal name of the inputs passed to a function?
Parameters
How do you add an element to the end of a list?
my_list.append(item)
What is the purpose of the else statement in Python?
to define a block of code that runs when all other conditions are false
What do you use to define a function in Python?
def
How do you convert a string "123" to an integer in Python?
int("123")
What is the random function to randomly select an element from a list?
How do you remove the 5th element of a list called x
x.remove(4)
Identify one error in the code below
if 6 + 1 = 7;
print("Hi guys")
else;
print("Goodbye guys"(
Either the semicolons after the if statements, or the if 6 + 1 = 7 only having one equal sign instead of two.
Explain what 2 of the 3 following operators do
>= , == , !=
Check if a value is more than or equal to, if it is equal to, or not equal to
How could you get the last element of a list?
my_list = [2, 4, 7]
my_list[len(my_list) - 1]