for i in range(6):
print(i)
0
1
2
3
4
5
This code will print out the numbers consecutively in the range of 6, beginning from 0 and ending before 6 to fulfill the 6 integers that will be printed.
Loop 1-10
for i in range(1,11):
print(i)
it loops it
What would this if / else statement’s output be if pie = yes?
pie = input(“do you want pie? (yes / no)”)
if pie == “yes”:
print(“one pie coming right up”)
else:
print(“okay”)
“one pie coming right up”
Since pie == “yes”, then “one pie coming right up” will be printed as the output.
age = input("enter your age: ")
if age < 13:
print("you cannot create an account")
else:
print("you can create an account")
There is no integer.
A number type code cannot be run if its not supported by an integer.
What is the name of the concept where both statements must be true so the output is true?
and
and is the concept where both requirements of an if statement must be true.
What would this code’s output be?
user = input("Enter username: ")
passs = int(input("Enter password: "))
if user == student and passs == 1234:
print("Welcome student!")
else:
print("Welcome!")
Enter username: student
Enter password: 1234
Welcome student!
Loop print hello 5 times
for i in range(5):
print("hello")
it prints hello 5 times
What would this if / else statement’s output be if choice = sandwich?
choice = input(“do you want a sandwich or pizza?”)
if choice == “pizza”:
print(“pizza is nice”)
else:
print(“one”, choice, “coming right up”)
“one sandwich coming right up”
Since sandwich falls into the else statement’s logic, then the sentence “one sandwich coming right up” is printed.
color = int(input("enter your favorite color: "))
if color == "red" or color == "blue":
print("those are such cool colors")
else:
print("nice")
There is an integer.
Integers are only for numbers.
What do you use as a backup in python?
else
After an if statement, commonly following it is an else statement to set up what will happen if the condition of the if statement is not met.
What would this code’s output be?
for i in range (0, 21, 2):
if i % 2 == 0:
print(i)
else:
print(“ “)
0
2
4
6
8
10
12
16
18
20
Loop print 1-5 backwards
for i in range(5, 0, -1):
print(i)
it prints 1-5 backwards.
What would this if / else statement’s output be if statistics >= 6 ft?
statistics = int(input(“how tall are you rounded to the nearest foot?”))
if statistics >= 5:
print(“that’s good!”)
elif statistics >= 6:
print(“that’s really tall!”)
else:
print(“cool!”)
“that’s really tall!”
The elif line sets up for “that’s really tall!” to be printed if statistics >= 6.
for i in range(1, 7):
if i % 2 = 0:
print("even")
else:
print("odd")
The "=" should be "=="
"=" is equal to in code, "==" is exactlly what it is equal to in command.
Which one of the following makes xor false?
A: T & T
B: F & T
C: T & F
XOR is true when only one of each value is involved, if there are two trues or two falses, XOR is false.