Python实现计算器功能

2023-01-31 05:01:19 python 功能 计算器

#!/usr/bin/python
# -*- coding:UTF-8 -*-

def sum(options,x,y):
    t = options
    if(t == "+"):
        print "x+y=",x+y
    elif(t == "-"):
        print "x-y=",x-y
    elif(t == "*"):
        print "x*y=",x*y
    else:
        print "x/y=",x/y

def main():
    options = raw_input("Please enter a method:")
    x = input("Enter a Num:")
    y = input("Enter another Num:")
    sum(options,x,y)
   
if __name__ == '__main__':
    main()

 

 

相关文章