Help please
x = input("Put the first number")
y =input("Put the first number")
name = input("Put sign /, *, +, -" )
if name == "/" :
print(x / y)
if name == "*" :
print(x * y)
if name == "+" :
print(x + y)
if name == "-" :
print(x - y)
Answers
Question:-
Remove the errors in the following code.
Answer:-
Given code, (Language:- Python)
x = input("Put the first number")
y =input("Put the second number")
name = input("Put sign /, *, +, -" )
if name == "/" :
print(x / y)
if name == "*" :
print(x * y)
if name == "+" :
print(x + y)
if name == "-" :
print(x - y)
First of all, your code has some errors.
x and y are string variables. String variables cannot be subtracted,multiplied or divided.
Write the following code and the problem will be solved.
Here is the code given after removing the errors.
x = int(input("Put the first number"))
y =int(input("Put the second number"))
name = input("Put sign /, *, +, -" )
if name == "/" :
print(x / y)
if name == "*" :
print(x * y)
if name == "+" :
print(x + y)
if name == "-" :
print(x - y)
Now, x and y are integer variables.
Thank you.
Answer:
Answer in attachment.....