Program Codes Flashcards
Favorite Number + 1 Ex.
prompt = “What is your favorite number? “
favorite = eval(input(prompt))
print(“My favorite number is”, favorite + 1, “one more.”)
What is Today Ex.
day = input(“What day is today? “)
print(“Today is”, day)
Operators and Operands Ex.
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
For Large Numbers Ex.
print(1,000,000) - incorrect
print(1_000_000) - correct
Strings and Concatenation Ex.
first = 10 second = 15 print(first + second) first = "10" second = "15" print(first + second)
Hours Worked Calculation Ex.
hours = eval(input(“Enter Hours: “))
rate = eval(input(“Enter Rate:”))
pay= hours * rate
print (“Pay” ,pay)