+ 2

How do I Create a function that converts a float to a string and double it.

def double_float(this_float): # TO DO BELOW: Let the variable doubled = this_float multiplied by 2 # Prints out what this_float doubled is. print(str(doubled) + ' is ' + str(this_float) + ' doubled.') # insert the float you want doubled double_float(319.16)

20th Jun 2018, 11:36 PM
Chris Sheffield
Chris Sheffield - avatar
4 ответов
+ 3
Thank you this is a big help George Ryan
21st Jun 2018, 1:02 PM
Chris Sheffield
Chris Sheffield - avatar
+ 1
def double_float(float): doubledFloat=float*2 floatString=str(doubledFloat) print(floatString) double_float(2.5)
21st Jun 2018, 12:33 PM
George Ryan
George Ryan - avatar
+ 1
prints 5.0
21st Jun 2018, 12:34 PM
George Ryan
George Ryan - avatar
+ 1
Also in order to print the float you do not need to convert it to a string
21st Jun 2018, 2:03 PM
George Ryan
George Ryan - avatar