+ 1

How do u change an interger into a float manually.

conversion.An example: 1) bill =float(input("enter number")) 2) donation =0.01*bill 3) print(" donation") the problem being the output of the code above is cleary wrong. So how do l fix this

13th Dec 2016, 9:21 PM
Coran
Coran - avatar
2 Antworten
+ 4
bill =float(input("enter number")) 2) donation =0.01*bill 3) print(" donation") In your above you are converting input value to float exactly right but problem is in your print statement. You put donation variable in double quotes which becomes a string. Just remove double quotes like print (donation ) You will get your desired results
14th Dec 2016, 3:06 AM
Waqas Asghar Bhalli
Waqas Asghar Bhalli - avatar
0
Does the float() function do what you need? Say you have an integer x = 1 ... float(x) will result in 1.0 The float function won't actually change the value of x on its own, so you need to reassign x as in: x = float(x)
13th Dec 2016, 9:40 PM
Antek