0% found this document useful (0 votes)
4 views3 pages

Lab No 15 Ha

The document contains a Python code for a simple calculator that performs addition, subtraction, multiplication, and division. It provides a user interface for inputting choices and numbers, and it continues to run until the user decides to exit. The code includes examples of usage and concludes with a note indicating the end of the program.

Uploaded by

Mohammad Hassam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Lab No 15 Ha

The document contains a Python code for a simple calculator that performs addition, subtraction, multiplication, and division. It provides a user interface for inputting choices and numbers, and it continues to run until the user decides to exit. The code includes examples of usage and concludes with a note indicating the end of the program.

Uploaded by

Mohammad Hassam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

5/21/24, 12:27 PM Lab no 15 ha

Lab No:15 Date:21\05\2024

Name:Muhammad Hassam Roll No:2k23-ELE-83

file:///C:/Users/Project Lab/Downloads/Lab no 15 ha.html 1/3


5/21/24, 12:27 PM Lab no 15 ha

In [12]: """
Write a code in python to make calculator
"""
while True:
print("A : Addition")
print("S : Subtraction")
print("M : Multiplication")
print("D : Division")
print("E : Exit")
choice = input("Enter your choice: ")
if choice == "a" or choice == "A":
print("Addition")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a + b
print(str(a) + " + " + str(b) + " = " + str(answer))
elif choice == "a" or choice == "s":
print("substraction")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a - b
print(str(a) + " - " + str(b) + " = " + str(answer))
elif choice == "m" or choice == "M":
print("Multiplication")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a + b
print(str(a) + " * " + str(b) + " = " + str(answer))
elif choice == "d" or choice =="D":
print("Division")
a = int(input("Enter First Number: "))
b = int(input("Enter Second Number: "))
answer = a/b
print(str(a) + " / " + str(b) + " = " + str(answer))
elif choice == "e" or choice== "E":
print("End of program")
break

A : Addition
S : Subtraction
M : Multiplication
D : Division
E : Exit
Enter your choice: a
Addition
Enter First Number: 100
Enter Second Number: 50
100 + 50 = 150
A : Addition
S : Subtraction
M : Multiplication
D : Division
E : Exit
Enter your choice: e
End of program

file:///C:/Users/Project Lab/Downloads/Lab no 15 ha.html 2/3


5/21/24, 12:27 PM Lab no 15 ha

Conclusion:

file:///C:/Users/Project Lab/Downloads/Lab no 15 ha.html 3/3

You might also like