Skip to content

import operator ops = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv, # Use truediv for floating-point division '**': operator.pow } while True: try: num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: ")) op = input("Enter the operation (+, -, *, /, **): ") if op in ops: result = ops[op](num1, num2) print(f"Result: {result}") break # Exit the loop if the operation is successful else: print("Invalid operation. Please choose from +, -, *, /, **.") except ValueError: print("Invalid input. Please enter numbers only.") #1

@Kipkemoi-coder

Description

@Kipkemoi-coder
No description provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions