Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me to add the ReGex operator to my calculator? Instruction: You need to check whether the input is string or float or

Can someone help me to add the ReGex operator to my calculator?

Instruction:

  • You need to check whether the input is string or float or integer, or complex and will return a message accordingly.
  • You need to accept only float or integer.

My calculator code is below:

P.S. Im using google collab.

defbasic_calc(): print("Selectoperation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") print("5.Modulo") choices=('1','2','3','4') choice=input()  ifchoiceinchoices:  num1=float(input("Enterthefirstnumber:")) num2=float(input("Enterthesecondnumber:")) total=0  ifchoice=='1': print(num1,"+",num2,"=",add(num1,num2)) elifchoice=='2': print(num1,"-",num2,"=",subtract(num1,num2) elifchoice=='3': print(num1,"*",num2,"=",multiply(num1,num2) elifchoice=='4': print(num1,"/",num2,"=",divide(num1,num2) elifchoice=='5': print(num1,"%",num2,"=",modulo(num1,num2) break else: print('InvalidInput') 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions