What is missing in this piece of code?
Print(Hello World)
What is, " " ?
What is a variable?
What is, containers for storing data values?
What is a function
What is, a block of statements that return a specific task?
What is a loop?
What is, a piece of code used for repeating over a sequence once or infinite amount of times?
What does this print?
print("Hello World!")
What is, Hello World in the console?
What is a Syntax Error give a definition or example.
What is, Definition: When the code violates Python’s syntax rules?
Example: Missing a colon after an "if" statement or using an invalid character?
How many times would this print?
x = range(6)
for n in x:
print(n)
What is, 5 times?
Can functions be called multiple times?
What is, yes?
What does an else do in a for loop?
What is, when the for loop does not reach its value or statement causing it to run the else?
What does this piece of code do?
def numbers(a, b):
return a + b
print(numbers(5, 3))
What is, adds 5 + 3 and prints 8 into the console?
What is a Name Error, give a definition or example?
What is, Definition: When a variable or function name is not defined?
Example: The variable is not defined?
What can be a variable?
What is, everything (numbers, letters, etc)?
What is the outcome of calling this function?
def greet(name):
print("Hello", name)
greet("John")
What is, Hello John ?
What is a for loop, and give an example.
What is, a loop used for iterating a sequence, such as a list, tuple, dictionary, set, or string?
Example: (can be different)
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
What does this piece of code do?
import random
var = random.randint(1, 9)
print("What is your number?")
var2 = input()
var2 = int(var2)
if var2 == var:
print("Correct")
else:
print("Incorrect")
What is, gets a number from random, asks for your input, then turns your input into an integer and compares var (random number) with var2 (your input). If your code is the same it will say correct in the console and if not it will say incorrect in the console?
Why would this error: int = 10.8
What is, int only being able to accept whole numbers?
Can a variable be changed?
A. No
B. Yes
C. Sometimes under certain circumstances
What is, B: Yes?
Why will the function not run?
def kahoot()
print ('"uh what the?"')
print("kahoot()")
What is, because of the quotes in line 3, which cause the code to print: kahoot() instead of the function?
Give an example of a while loop that repeats Hello world as long as X is equal to 5.
What is,
x = 5
while x = 5:
print("Hello world") ?
What can be done to shorten this code:
import turtle
turt = turtle.Turtle()
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
turt.forward(10)
turt.right(90)
What is, making the code into a def and calling it?
What is a runtime error?
What is, an error that happens while your program is executing causing it to fail?
What is wrong with this code, explain? If there is nothing explain.
import turtle
turt = turtle.Turtle()
x = 5
y = 6
z = 7
X = 8
Y = 7
Z = 6
turt.goto(x, X, Y)
turt.forward(X)
What is, nothing variables are not case sensitive?
What is another use for functions that isn't returning values. Jonathan gave an example of this use on day 2.
(+150 points if you know the example)
What is, for organizing, and to make your code more easily editable, so if you want to change a piece of code that you used many times, its as easy as going to the function and fixing it there?
EXAMPLE: spaghetti and computer wires ?
How do you stop a loop with one word in the code?
What is, break?
What does this code do?
def yxz(num):
if num <= 1:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
print(yxz(17)) # Output: True
What is, to check if a number is prime?