-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetic operations.py
More file actions
45 lines (35 loc) · 1.13 KB
/
Arithmetic operations.py
File metadata and controls
45 lines (35 loc) · 1.13 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
# Python has multiple arithmetic operations for calculations
""""
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division (float)
// Floor Division
% Modulus (remainder)
** Exponentiation
Built-in math Module Functions - provides extra math capabilities.
import math
# Basic math functions
print(math.sqrt(16)) # Square root → 4.0
print(math.pow(2, 3)) # Power → 8.0
print(math.factorial(5)) # Factorial → 120
print(math.gcd(12, 18)) # Greatest Common Divisor → 6
# Rounding functions
print(math.ceil(4.3)) # Round up → 5
print(math.floor(4.7)) # Round down → 4
# Constants
print(math.pi) # 3.141592653589793
print(math.e) # 2.718281828459045
"""
# A few examples
num1 = 5
num2 = 10
Addition = num1 + num2
print("Sum of both numbers is: ",Addition)
Division = num2/num1
print("Division of number 2 by number 1 is: ",Division)
Multiply = num1*num2
print("Multiplication of num1 and num2 is :", Multiply)
powerof = num1 ** num2
print(" Exponential of num1 ** num2 i.e. num1 to the power of num2 is : ", powerof)