Python Examples: Difference between revisions
From Lucca's Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
Calculate the average of three numbers | Calculate the average of three numbers | ||
avg = (num1+num2+num3)/3 | avg = (num1+num2+num3)/3 | ||
Display a variable inside an f string and round it to only have 2 decimals, like with money | |||
monthly_payment = 1000.0000 | |||
print(f'The monthly payment is {monthly_payment:.2f}.') |
Revision as of 10:36, 29 August 2025
Calculate the average of three numbers
avg = (num1+num2+num3)/3
Display a variable inside an f string and round it to only have 2 decimals, like with money
monthly_payment = 1000.0000 print(f'The monthly payment is {monthly_payment:.2f}.')