0
Why its 20 not 20.0.......since in the last problem the answer was in float...how to declare whether its an integer or float
3 Answers
+ 3
A float is created by dividing:
e.g
2/4
also adding decimals
4.5 + 6.5 = 11.0
if a calculation has a decimal, the answer will be a float :)
eg 4 + 5.0 + 7 + 4 = 20.0
but
4+5+7+4=20
I cant give an exactly answer, because i cant see the Q
+ 2
The division in Python gives float result by default.
You can get integer results too, by using the double backlash:
print(3 // 2) # 1
Or, by using the int() function:
print(int(3 / 2)) # 1
print(int(3.1415)) # 3
+ 1
also for input
float:
example=float(input())
integer:
example=int(input())