Program Codes Flashcards

1
Q

Favorite Number + 1 Ex.

A

prompt = “What is your favorite number? “
favorite = eval(input(prompt))
print(“My favorite number is”, favorite + 1, “one more.”)

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

What is Today Ex.

A

day = input(“What day is today? “)

print(“Today is”, day)

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

Operators and Operands Ex.

A

20 + 32 print(20+30)

year - 1 year =2021
print(“last year was”, year - 1)

price * tax_rate =.06
print(“tax is”, price * tax_rate)
price = 20.65

90 / 60 (Division Answer) 1.5

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

For Large Numbers Ex.

A

print(1,000,000) - incorrect

print(1_000_000) - correct

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

Strings and Concatenation Ex.

A
first = 10
second = 15
print(first + second)
first = "10"
second = "15"
print(first + second)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Hours Worked Calculation Ex.

A

hours = eval(input(“Enter Hours: “))
rate = eval(input(“Enter Rate:”))
pay= hours * rate
print (“Pay” ,pay)

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