Discussions Events Study Material Jobs
Basic Calculator with if elif Using Python - Uniwaly

Explore Diverse Conversations

Basic Calculator with if elif Using Python

Posted By: UmairMehmood Published On: 13 June 2025 At: 13:23 PM

Input two numbers and an operator (+, -, *, /)

Perform and print the operation using conditional statements

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))
operator = input("Enter operator (+, -, *, /): ")
if operator == '+':
    print("Result:", num1 + num2)
elif operator == '-':
    print("Result:", num1 - num2)
elif operator == '*':
    print("Result:", num1 * num2)
elif operator == '/':
    if num2 != 0:
        print("Result:", num1 / num2)
    else:
        print("Error: Cannot divide by zero.")
else:
    print("Invalid operator!")


Tags:

python basic calculator if elif python
Login to like

Posted By:

Author Profile

UmairMehmood

11 days ago

Join the conversation!

Login to Comment

Discover More Articles

Check if Character is a Vowel or Consonant using Python

Communication & Coordination Officer - The Urban Unit Jobs 2025

Indian BSF soldier arrested on Pakistani soil by Pak Rangers

فلم پی کے میں دکھایا گیا ایک سین حقیقت میں تبدیل

Heavy Industries Taxila Education City Jobs 2025 - Teachers & Others HITEC Latest Jobs

Survey Supervisors - The Urban Unit Jobs 2025

Your Rights Online: How to Report and Delete AI-Generated Fake Content Featuring You

Write a program to reverse a list using a loop using Python

INSPECTORATE OF MINES, PUNJAB, MINES & MINERALS DEPARTMENT 2025 - 14/2025

Input 5 numbers from the user and store them in a list. Then print the list Using Python