+ 3
What is wrong in my code ?
10 Antworten
+ 7
Here is the correct code:
https://code.sololearn.com/ckn6igOCkFn8/?ref=app
+ 3
Ooo thank u
+ 1
This is the right code:
print("Options \n")
print("1.To add\n")
print("2.To subtract\n")
print("3.To multiply\n")
print("4.To divide\n")
x= int(input("Enter your choice\n"))
if x==1 :
num1=int(input("Enter 1st number to be added\n"))
num2=int(input("Enter 2nd number yo be adeed\n"))
sum=num1+num2
print("sum" , sum)
elif x==2:
num1=int(input("Enter 1st number to be subtracted\n"))
num2=int(input("Enter 2nd number yo be subtracted\n"))
sub=num1-num2
print("sub" , sub)
elif x==3:
num1=int(input("Enter 1st number to be miltiplied\n"))
num2=int(input("Enter 2nd number yo be multiplied\n"))
pro=num1*num2
print("product" , pro)
elif x==4:
num1=int(input("Enter 1st number to be divided\n"))
num2=int(input("Enter 2nd number yo be divided\n"))
quo=num1//num2
print("quotient" , quo)
+ 1
I had to remove the indentation, that is not needed in the first five lines, and I had to adjust the indentation inside the "if" cycles. Furthermore, I had to substitute "insert" with "input" and correct the first "if" sentence.
+ 1
https://code.sololearn.com/cphBNc2M7Iuk/?ref=app
Still it showing error in line 7
0
what is this language sir
- 1
print("Options \n")
print("1.To add\n")
print("2.To subtract\n")
print("3.To multiply\n")
print("4.To divide\n")
x = int(input("Enter your choice\n"))
if x==1:
num1=int(input("Enter 1st number to be added\n"))
num2=int(input("Enter 2nd number yo be adeed\n"))
sum=num1+num2
print("sum" , sum)
elif x==2:
num1=int(input("Enter 1st number to be subtracted\n"))
num2=int(input("Enter 2nd number yo be subtracted\n"))
sub=num1-num2
print("sub" , sub)
elif x==3:
num1=int(input("Enter 1st number to be miltiplied\n"))
num2=int(input("Enter 2nd number yo be multiplied\n"))
pro=num1*num2
print("product" , pro)
elif x==4:
num1=int(input("Enter 1st number to be divided\n"))
num2=int(input("Enter 2nd number yo be divided\n"))
quo=num1//num2
print("quotient" , quo)
mostly indentation errors and you somethimes wrote insert instead of input ...