The document describes an experiment to write a Python program to create a simple calculator. The program takes in two numbers, a and b, displays operation options 1-4, reads the choice, then performs the chosen calculation - addition, subtraction, multiplication, or division - and prints the result. It handles invalid choices. The program was successfully executed and verified.
The document describes an experiment to write a Python program to create a simple calculator. The program takes in two numbers, a and b, displays operation options 1-4, reads the choice, then performs the chosen calculation - addition, subtraction, multiplication, or division - and prints the result. It handles invalid choices. The program was successfully executed and verified.
The document describes an experiment to write a Python program to create a simple calculator. The program takes in two numbers, a and b, displays operation options 1-4, reads the choice, then performs the chosen calculation - addition, subtraction, multiplication, or division - and prints the result. It handles invalid choices. The program was successfully executed and verified.
1. Read the value of a and b. 2. Print the choices. 3. Read the choice as n. 4. if (n>0) and(n<5) If n==1 Print the sum of a and b. eliIf n==2 Print the difference of a and b. elif n==3 Print the product of a and b. else Print the quotient of a divided by b. 5. else Print Invalid choice. Source Code:
Input and Output:
Conclusion: Thus, the Python program to develop a simple calculator is executed