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

Why Google stopped showing the card of summary of your site's performance on Google Search ?

Describe the process of microteaching by focusing its reflective nature in the development of novice teachers. What is the role of supervisor in this process?

Visiting / Teaching Faculty Jobs in University of Veterinary and Animal Sciences Lahore 2025

Simple Number Guessing Game Using Python

10-Day PhD Interview Prep Series: Essential Questions & Answers

Survey Supervisors - The Urban Unit Jobs 2025

Air University Main Campus - How to Apply

Opening a Bank Account for Minors in Pakistan: A Comprehensive Guide

Why does pyqtgraph PlotWidget stutter/lags when I pan, zoom with mouse while graph updates?

Login System Hardcoded Using Python