Tagged: float

Everything tagged "float", newest first.

Coding Practice ·

Python Coding Exercise #42: Gift Tax Calculator

A beginner Python exercise on if, elif and else with several ranges — calculate gift tax from a table of brackets, and learn to turn a complicated table into a simple reference table before writing any code.

Coding Practice ·

Python Coding Exercise #31: Typecasting

A beginner Python exercise on type conversion — use int() to split a decimal number into its integer part and decimal part, and see why the decimal part can print with extra digits.

Coding Practice ·

Python Coding Exercise #28: Solving a Quadratic Equation

A beginner Python exercise that turns the quadratic formula into code — read a, b and c, calculate the discriminant, and use sqrt() to find the two roots, with attention to brackets and order of operations.

Coding Practice ·

Python Coding Exercise #27: Hypotenuse of a Right-Angled Triangle

A beginner Python exercise on the math module — use Pythagoras' theorem and sqrt() to find the hypotenuse of a right-angled triangle, read decimal sides with float(), and format the answer to two decimal places.

Coding Practice ·

Python Coding Exercise #22: Area and Circumference of a Circle

A beginner Python exercise on the math module — read a radius, calculate a circle's area and circumference using pi, and round the answers to two decimal places.

Coding Practice ·

Python Coding Exercise #19: Loyalty Bonus

A beginner Python debugging exercise on if and else — why two separate if statements can both run when the first one changes the variable the second one checks, and how to fix it.

Coding Practice ·

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.

Coding Practice ·

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.

Coding Practice ·

Python Coding Exercise #14: Soup or No Soup

A beginner Python exercise on if/else with strings — ask for a name, skip the order for one particular customer, and work out the total cost for everyone else without floating-point surprises.

Coding Practice ·

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.

All tags