float

So far we have dealt with textual values (strings) and integer numbers (ints). Yet some applications require dealing with floating-point numbers. In python, those numbers are called floats. To read a floating-point number from the input, one can write a simple program:
a = int(input())
b = float(input())

print(a, type(a))
print(b, type(b))
print(a + b - 1, type(a + b - 1))
In case the inputted numbers were 10 and 7.7, the program would print the following:
10 <class 'int'>
7.7 <class 'float'>
16.7 <class 'float'>
 
We can define floating-point numbers as regular variables:
pi = 3.14159265359
r = 2
print(2 * pi * r)
This program would compute the circumference of the circle on the right and would print 12.56637061436.
notion image

Challenge

Given two sides of a rectangle h and w, compute and print its surface area.
Input
Output
2 3
6
1.1 3.5
3.85
 
Note: You might notice that the python output for the second example is not exactly 3.85 but rather 3.8500000000000005. That’s because of the way our computers handle floating-point numbers. Watch this video to get more insights into how this magic happens:
Video preview
Video made by Computerphile (Floating-Point Numbers - Computerphile)
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue