语法错误:(unicode错误)“ unicodeescape”编解码器无法解码位置51-52中的字节:格式错误的\ N字符转义

时间:2019-07-12 05:56:27

标签: python python-3.x

import math

import cmath

print("************************************************")

print("Welcome to Numerology!")

print("************************************************")

def addition():

    print(a ,"+" ,b ,"=", a+b)

def subtraction():

    print(a, "-",b,"=", a-b) 

def division():

    print(a, "/", b, a/b) 

def squareroot():

     print("The squareroot of the sum of your numbers is",y)

def cos():

    print(a,"cos",b,"=",a*cos(b) )

def sin():

    print(a,"sin", b, "=", a*sin(b) )

def multiply():

    print(a,"x", b, "=", a*b)

a= int(input("What's your first number?\n"))

b= int(input("What's your second number?\n"))

y= cmath.sqrt(a+b)

s= subtraction

d= division

p= addition

sq= squareroot

c= cos

m= multiply

si= sin

while True:

    print("What operator would you like to use?\n  s for subtraction, d for 

division, m for  multiplication, sq for squareroot, c for cos,si for sin, and 

p for addition ")

    choice = input("Your choice\n")

    if choice == "s":

        subtraction() 

    elif choice == "d":

        division()

    elif choice == "p":

        addition()

    elif choice == "sq":

        squareroot()

    elif choice == "c":

        cos()

    elif choice == "si":

        sin()

    elif choice == "m":

        multiply()

    res= input("Would you like to choose a different  operator? Yes\No:")

    if res == "Yes":

        print("What operator would you like to use?\n  s for subtraction, d 

for division, m for  multiplication, sq for squareroot, c for cos,si for sin, and p for addition ")
        choice = input("Your choice\n")

    elif res == "No":

        print("Thank you for using Numerology")

1 个答案:

答案 0 :(得分:0)

import math

import cmath

print("************************************************")

print("Welcome to Numerology!")

print("************************************************")

def addition():

    print(a ,"+" ,b ,"=", a+b)

def subtraction():

    print(a, "-",b,"=", a-b) 

def division():

    print(a, "/", b, a/b) 

def squareroot():

     print("The squareroot of the sum of your numbers is",y)

def cos():

    print(a,"cos",b,"=",a*cos(b) )

def sin():

    print(a,"sin", b, "=", a*sin(b) )

def multiply():

    print(a,"x", b, "=", a*b)

a= int(input("What's your first number?\n"))

b= int(input("What's your second number?\n"))

y= cmath.sqrt(a+b)

s= subtraction

d= division

p= addition

sq= squareroot

c= cos

m= multiply

si= sin

while True:

    print("What operator would you like to use?\n  s for subtraction, d for division, m for  multiplication, sq for squareroot, c for cos,si for sin, and p for addition ")

    choice = input("Your choice\n")

    if choice == "s":

        subtraction() 

    elif choice == "d":

        division()

    elif choice == "p":

        addition()

    elif choice == "sq":

        squareroot()

    elif choice == "c":

        cos()

    elif choice == "si":

        sin()

    elif choice == "m":

        multiply()
    else:
      print("Wrong choice")
    res= input(r"Would you like to choose a different operator ? Yes\No:")

    if res == "Yes":

        print("What operator would you like to use?\n  s for subtraction, d for division, m for  multiplication, sq for squareroot, c for cos,si for sin, and p for addition ")
        choice = input("Your choice\n")

    elif res == "No":

        print("Thank you for using Numerology")

Checkout this link希望它会起作用。