Computer Science, asked by kasar4178, 6 months ago

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

Answered by anindyaadhikari13
2

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.

Answered by Anonymous
10

Answer:

Answer in attachment.....

Attachments:
Similar questions