Repository navigation
Expand file tree
/
Copy path098-Arithmetic-Operators.py
More file actions
94 lines (79 loc) · 2.97 KB
/
Copy path098-Arithmetic-Operators.py
File metadata and controls
94 lines (79 loc) · 2.97 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
90
91
92
93
94
"""
===============================================================================
File Name : 98-Arithmetic-Operators.py
Description : Arithmetic Operators in Python
Author : Shaik Mahaboob Basha
===============================================================================
Definition:
Arithmetic operators are used to perform mathematical operations on numeric
values.
Arithmetic Operators:
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Floor Division (//)
6. Modulus (%)
7. Exponentiation (**)
Syntax:
operand1 operator operand2
Example:
10 + 5
"""
# -----------------------------------------------------------------------------
# Assigning values to two variables.
# -----------------------------------------------------------------------------
number1 = 20
number2 = 6
# -----------------------------------------------------------------------------
# Displaying the input values.
# -----------------------------------------------------------------------------
print("First Number :", number1)
# Output:
# First Number : 20
print("Second Number :", number2)
# Output:
# Second Number : 6
print()
# -----------------------------------------------------------------------------
# Performing addition.
# -----------------------------------------------------------------------------
print("Addition (+) :", number1 + number2)
# Output:
# Addition (+) : 26
# -----------------------------------------------------------------------------
# Performing subtraction.
# -----------------------------------------------------------------------------
print("Subtraction (-) :", number1 - number2)
# Output:
# Subtraction (-) : 14
# -----------------------------------------------------------------------------
# Performing multiplication.
# -----------------------------------------------------------------------------
print("Multiplication (*) :", number1 * number2)
# Output:
# Multiplication (*) : 120
# -----------------------------------------------------------------------------
# Performing division.
# -----------------------------------------------------------------------------
print("Division (/) :", number1 / number2)
# Output:
# Division (/) : 3.3333333333333335
# -----------------------------------------------------------------------------
# Performing floor division.
# -----------------------------------------------------------------------------
print("Floor Division (//) :", number1 // number2)
# Output:
# Floor Division (//) : 3
# -----------------------------------------------------------------------------
# Finding the remainder using modulus.
# -----------------------------------------------------------------------------
print("Modulus (%) :", number1 % number2)
# Output:
# Modulus (%) : 2
# -----------------------------------------------------------------------------
# Performing exponentiation.
# -----------------------------------------------------------------------------
print("Exponentiation (**) :", number1 ** 2)
# Output:
# Exponentiation (**) : 400