Repository navigation
Expand file tree
/
Copy path054-Basic-Calculator-Using-User-Input.py
More file actions
89 lines (74 loc) · 3.68 KB
/
Copy path054-Basic-Calculator-Using-User-Input.py
File metadata and controls
89 lines (74 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""
===============================================================================
Basic Calculator Using User Input
===============================================================================
Program Description:
--------------------
This program demonstrates a basic calculator using user input.
The user enters two numbers, and the program performs basic arithmetic
operations such as addition, subtraction, multiplication, division,
modulus, floor division, and exponentiation.
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 54-Basic-Calculator-Using-User-Input.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Reading the first number from the user.
# -----------------------------------------------------------------------------
number1 = float(input("Enter the First Number: "))
# Example Input: 20
# -----------------------------------------------------------------------------
# Reading the second number from the user.
# -----------------------------------------------------------------------------
number2 = float(input("Enter the Second Number: "))
# Example Input: 5
# -----------------------------------------------------------------------------
# Displaying the entered values.
# -----------------------------------------------------------------------------
print("First Number :", number1)
print("Second Number :", number2)
# Example Output:
# First Number : 20.0
# Second Number : 5.0
# -----------------------------------------------------------------------------
# Performing addition.
# -----------------------------------------------------------------------------
print("Addition :", number1 + number2)
# Example Output: Addition : 25.0
# -----------------------------------------------------------------------------
# Performing subtraction.
# -----------------------------------------------------------------------------
print("Subtraction :", number1 - number2)
# Example Output: Subtraction : 15.0
# -----------------------------------------------------------------------------
# Performing multiplication.
# -----------------------------------------------------------------------------
print("Multiplication :", number1 * number2)
# Example Output: Multiplication : 100.0
# -----------------------------------------------------------------------------
# Performing division.
# -----------------------------------------------------------------------------
print("Division :", number1 / number2)
# Example Output: Division : 4.0
# -----------------------------------------------------------------------------
# Performing modulus operation.
# -----------------------------------------------------------------------------
print("Modulus :", number1 % number2)
# Example Output: Modulus : 0.0
# -----------------------------------------------------------------------------
# Performing floor division.
# -----------------------------------------------------------------------------
print("Floor Division :", number1 // number2)
# Example Output: Floor Division : 4.0
# -----------------------------------------------------------------------------
# Performing exponentiation.
# -----------------------------------------------------------------------------
print("Exponentiation :", number1 ** number2)
# Example Output: Exponentiation : 3200000.0
# -----------------------------------------------------------------------------
# Displaying a completion message.
# -----------------------------------------------------------------------------
print("Program Completed.")
# Output:
# Program Completed.