Tagged: f-strings
Everything tagged "f-strings", newest first.
Python Coding Exercise #47: PIN and Number of Attempts
A beginner Python exercise on loops and counters — keep asking for a PIN until it is correct, count the attempts, and print a different message when it takes only one try.
Python Coding Exercise #18: Daily Wages
A beginner Python exercise on if statements and arithmetic — calculate a day's pay from the hourly wage and hours worked, with double pay on Sundays.
Python Coding Exercise #17: Temperatures
A beginner Python exercise that converts Fahrenheit to Celsius and prints an extra message when the result is below zero — practice with formulas, floats and if statements.
Python Coding Exercise #16: Calculator
A beginner Python exercise on comparing strings with if statements — build a small calculator that adds, subtracts or multiplies two numbers depending on the operation the user types.
Python Coding Exercise #11: Food Expenditure
A beginner Python exercise that combines int(), float(), arithmetic and a multi-line f-string — estimate a user's weekly and daily food expenditure from three inputs.
Python Coding Exercise #09: Calculations with Input
Three short beginner Python exercises that read numbers with input() and calculate with them — seconds in a number of days, the sum and product of two numbers, and the sum and mean of four numbers.
Python Coding Exercise #08: Converting Input to Integer
Two beginner Python exercises that turn input() into an integer with int() so it can be used in a calculation — multiplying a number by five, and working out someone's age from their birth year.
Python Coding Exercise #06: Arithmetics
A beginner Python exercise on arithmetic operators and f-strings — print the sum, difference, product and quotient of two variables so the program still works when the values change.
Python Coding Exercise #05: Extra Space
A beginner Python exercise on print() and whitespace — why commas in print() add extra spaces, and how f-strings give you exact control over the output.
Python Coding Exercise #04: User Input and f-Strings
Five beginner Python exercises that combine input() with f-strings — printing a name twice, adding exclamation marks, formatting an address, fixing an f-string program, and filling in a story.