Skip to main content

Posts

Showing posts with the label multiplication

Python - Basic Mathematical Calculator

🐍  In Python, write a code to let users carry out basic mathematical calculations that include addition, subtraction, multiplication, and division. Solution def basic_operation(a, b, opp):     if opp[0] == '+':         return a+b     elif opp[0] == '-':         return a-b     elif opp[0] == '*':         return a*b     elif opp[0] == '/':         return a/b if __name__ == '__main__':     a = float(input('Enter first number: '))     opp = input("+ - * / ")     b = float(input('Enter second number: '))     print(basic_operation(a, b, opp))