python 语言问题 80
我最近在学python语言,最近老师给发了两个个改错题,我看了几次没看出来,求大神帮忙看看指点指点1.whileTrue:print("Enteranumberopera...
我最近在学python语言,最近老师给发了两个个改错题,我看了几次没看出来,求大神帮忙看看指点指点
1.
while True:
print("Enter a number operation (+, -, /, *, **, %):")
o = input()
print("Input your first number")
f = input()
print("Input your second number:")
s = input()
if o == '%':
print(f % s)
if o == '**':
print(f ** s)
if o == '*':
print(f * s)
if o == '/':
print(f / s)
if o == '-':
print(f - s)
if o == '+':
print(f + s)
print("Are you done? (no or yes)")
answer = input()
if answer == "no":
break
2.
choice = 1
while choice == 1:
print("Choose an operation:")
print("1. +")
print("2. -")
print("3. *")
print("4. /")
print("5. %")
print("6. **")
op = -1
while op < 1 or op > 6:
op = int(input())
x = input("Enter first number:")
y = input("Enter second number:")
if op == 1:
print(x+y)
elif op == 2:
print(x-y)
elif op == 3:
print(x*y)
elif op == 4:
print(x/y)
elif op == 5:
print(x%y)
elif op == 6:
print(x**y)
choice = int(input("Enter 1 if you want to continue:")) 展开
1.
while True:
print("Enter a number operation (+, -, /, *, **, %):")
o = input()
print("Input your first number")
f = input()
print("Input your second number:")
s = input()
if o == '%':
print(f % s)
if o == '**':
print(f ** s)
if o == '*':
print(f * s)
if o == '/':
print(f / s)
if o == '-':
print(f - s)
if o == '+':
print(f + s)
print("Are you done? (no or yes)")
answer = input()
if answer == "no":
break
2.
choice = 1
while choice == 1:
print("Choose an operation:")
print("1. +")
print("2. -")
print("3. *")
print("4. /")
print("5. %")
print("6. **")
op = -1
while op < 1 or op > 6:
op = int(input())
x = input("Enter first number:")
y = input("Enter second number:")
if op == 1:
print(x+y)
elif op == 2:
print(x-y)
elif op == 3:
print(x*y)
elif op == 4:
print(x/y)
elif op == 5:
print(x%y)
elif op == 6:
print(x**y)
choice = int(input("Enter 1 if you want to continue:")) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询