In Class Handouts CH 2-4 Flashcards

1
Q

Write a python statement that assigns the sum of 10 and 14 to the variable total.

A

total = 10 +14

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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.

A

color = input(“Enter your favorite color: “)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What will be displayed after the following code is executed?
total = 0 
for count in range(1,4):
     total += count
print(total)
A

6

process:
1,2,3
1+2+3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What will be displayed after the following code is executed?
for num in range(0, 20, 5):
num += num
print(num)

A

30

process
0,5,10,15
0+5+10+15

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What will the following display?

num=100
num =99
print(num)

A

99

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

if x > 100:
y = 20
z = 40

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write an if statement that determine whether y is in the range 10 through 50, inclusive?

A

if y >= 10 and y <= 50:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly