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

NIU - NUR International University - Admission Process

Pension New Method Explained - Which Employees Not Eligible For Pension ?

Punjab Danish School New Jobs 2025 - Non Academic Staff Required

Critically discuss Quality and Access as to two problems in higher education. Suggest some ways to address these problems.

PSEB Pakistan Software Export Board Islamabad Jobs 2025

How to Attestation of Degrees/Diplomas/Certificates From HEC ?

Pakistan Television Corporation ( PTV ) New Jobs 2025

How to Keep a Camera Stream Active Across Pages Without Reinitializing the Camera on Each Page?

Superior University Admission Process

Explain the concept of economics of higher education in Pakistan. What are different ways of financing higher education in Pakistan?