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

Kazakhstan Government Scholarship - How to Apply ? - Complete Detail

Login System Hardcoded Using Python

International Scholarship without IELTS 2025

Jobs in Excise and Taxation

Understanding Anonymous Proxy Detection: Challenges, Implications, and Solutions

Chief Minister Punjab Wildlife Internship Program 2025

NADRA Internship Program 2025 for All Pakistani Fresher Graduates

Check if Character is a Vowel or Consonant using Python

Inspector ASF Seats announced through FPSC 2025

Discuss need of assessment in higher education in Pakistan? Up to what extent you are satisfied with the present assessment system and how it can be improved?