What is the error with this code?
print("This number is: " + 100)
What are the two types of loops you can make in Python?
for loop and while loop
What type is the variable, x?
x = 100
integer
Which three keywords in Python can you use for conditionals?
if, elif, else
What is the program that we are using to code our projects?
Bonus: What does IDE stand for?
PyCharm, Integrated Development Environment
What keyword do you use before the function name to start defining a function?
def
How many times will this loop run?
while True:
print("Hello")
This loop will not end unless you interrupt it in the console, or the program exceeds the memory limit and crashes.
What type is the variable, y?
y = input("Type a number: ")
string
What character do you put at the end of a line with a conditional keyword?
A colon
What version of Python are we using?
Python 3.10
What does the return keyword do in a function?
It exits the function and can return a value to be assigned to a variable.
What keyword can you use to exit a loop?
break
What is the type of the variable, z?
z = float(input("Type a number: "))
float
How many indents do you put for a block of code inside a conditional statement?
One indent (but you can have more depending on the code in the conditional statement like nested conditionals, loops, functions, etc.)
What language was Python originally implemented in?
The C programming language
What do you call a function that calls itself?
A recurive function
How many times will this loop run?
for i in range(3):
for j in range(5):
print((i+1) * (j+1))
15 times
What is the type of the variable, abc?
abc = (7, 15, 2004)
A tuple (of integers)
x = 15
if x % 3 == 0:
print("Divisible by 3")
elif x % 5 == 0:
print("Divisible by 5")
else:
print("Divisible by both 3 and 5")
"Divisible by 3"
What is another type of snake that is also a name for a distribution of Python that includes tools for data science and machine learning, and has package management, deployment, and environment management capabilities?
Anaconda
What is the difference between function parameters and arguments in Python?
Parameters are the names listed in the function definition, while arguments are the actual values passed into the function.
def add(a, b):
return a + b
num = add(10, 5)
What keyword can you use to go to the next iteration of a loop instead of executing the rest of the code in the loop?
continue
What is one difference between a list and a set?
A set only contains unique elements with no repeats, while lists can contain duplicate elements. Sets are also unordered, whereas lists are ordered and can be indexed by their position in the list.
How many elif statments can you have after an if statement? How many else statements can you have after an if statement?
elif - as many as you want/infinite or none
else - one or none
What year was Python invented? (+/- 3 years)
1991