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

8th Oct 2018, 4:02 PM
Jervis.J Vasanth
Jervis.J Vasanth - avatar
3 Antworten
+ 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
8th Oct 2018, 4:16 PM
Plurgie
Plurgie - avatar
+ 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
9th Oct 2018, 3:52 AM
Boris Batinkov
Boris Batinkov - avatar
+ 1
also for input float: example=float(input()) integer: example=int(input())
9th Oct 2018, 3:31 AM
BelowZer0
BelowZer0 - avatar