Previous

Variables and Types

4 / 6
Next

A Python variable of type int can only store integers: whole numbers like $5$ or $-2$. Decimal numbers like $3.14$ are stored in Python variables of type float.

pi = 3.14159
print(round(pi, 2)) # 3.14

With the function round we can round variables of type float to two decimal digits. Input can be cast to float like this:

print("Enter any number: ")
x = float(input())
Send

Decimal numbers

Hint
Beginner

Write a small application of a scale that weighs apples. The input is the weight of apples in kilograms. The output must be the total price, given that apples cost $1.99/kg.

Help
Solve
Reset
Run
Submit
 

Test results

Test result #
Expected output
Your output

Your email has been verified!