0

What exactly is wrong with this code

print ("enter the 1st number") X=input () print ("enter the second number") Y=input () print("enter the operator") Z=input () if Z=='x': print ("X*Y")

30th Apr 2021, 12:12 AM
$BANANA$
6 Respostas
+ 3
$BANANA$ I noted you are about 1/3 of the way through the Python Core tutorial. Please refer to lesson 15.1 which explains why int(input()) is required to define a string input from an integer input. Keep this in mind when you wish to create a float(input())
30th Apr 2021, 10:17 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
The problem with the code is it doesnt work.
30th Apr 2021, 12:32 AM
Brain & Bones
Brain & Bones - avatar
+ 2
To fix it change print(“X*Y”) to print (int(X)*int(Y)) https://code.sololearn.com/csV2U8N8Pw5t/?ref=app
30th Apr 2021, 12:33 AM
Brain & Bones
Brain & Bones - avatar
+ 1
Thanks Rik Wittkopp
1st May 2021, 8:02 PM
$BANANA$
0
Thanks Caleb
30th Apr 2021, 1:11 AM
$BANANA$
0
But can you explain why the int is added
30th Apr 2021, 1:15 AM
$BANANA$