Python Python Basics Types and Branching Numeric

why this script don't work

x = input(" Enter the first number : " )

y = input(" Enter the secound number : ")

float(x)

float(y)

print("The result : ", x + y)

3 Answers

Kent Åsvang
Kent Åsvang
18,814 Points

You need to store the value returned by float() into a variable.

    first_number = float(x)
    second_number = float(y)

and if you are going to use comma-separated values in your print-function you can remove the placeholder {}

Richie Sanchez
Richie Sanchez
975 Points

a more convoluted way (if I understood the desired output correctly):

x = input("Enter the first number: ") y = input("Enter the second number: ")

print("The result is:",float(int(x) + int(y)))

Output in Shell: 11.0

Gideon De Villiers
PRO
Gideon De Villiers
Pro Student 630 Points

x = float(input('Enter the first number ')) y = float(input('Enter the second number '))

print('The Result:', x+y)