In Class Handouts CH 2-4 Flashcards
Write a python statement that assigns the sum of 10 and 14 to the variable total.
total = 10 +14
Write Python code that prompts the user to enter his or her favorite color and assigns the user’s input to a variable named Color.
color = input(“Enter your favorite color: “)
What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total)
6
process:
1,2,3
1+2+3
What will be displayed after the following code is executed?
for num in range(0, 20, 5):
num += num
print(num)
30
process
0,5,10,15
0+5+10+15
What will the following display?
num=100
num =99
print(num)
99
Write an If statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100.
if x > 100:
y = 20
z = 40
Write an if statement that determine whether y is in the range 10 through 50, inclusive?
if y >= 10 and y <= 50: