Command line utility :-
import argparse
import sys
def calc(args):
if args.o =='Add':
return args.x + args.y
elif args.o =='sub':
return args.x - args.y
elif args.o =='div':
return args.x / args.y
elif args.o =='multi':
return args.x * args.y
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--x',type=float,default=1, help='Please enter the first number.')
parser.add_argument('--y',type=float,default=3.0, help='Please enter the second number.')
parser.add_argument('--o',type=str,default="Add", help='Please enter the operation.')
args = parser.parse_args()
Thanks you for commenting your questions. I will see question and respond you.