-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnumbers.py
76 lines (45 loc) · 1.41 KB
/
numbers.py
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
#A number is an arithmetic value used for representing the quantity and used in making calculations
#Python has three built-in numeric data types: integers,
#floating-point numbers, and complex numbers
#Integer
#An integer is a whole number, such as 1, 2, or 3. You can create an integer by assigning an integer value to a variable:
#
x = 10
#You can perform arithmetic operations with integers, such as addition, subtraction, multiplication, and division:
x = 10
y = 5
# Addition
z = x + y # z is 15
# Subtraction
z = x - y # z is 5
# Multiplication
z = x * y # z is 50
# Division
z = x / y # z is 2.0
Float
#A float is a number with a decimal point, such as 1.5 or 3.14.
# You can create a float by assigning a float value to a variable:
x = 3.14
#You can perform arithmetic operations with floats, just like with integers:
x = 3.14
y = 2.71
# Addition
z = x + y # z is 5.85
# Subtraction
z = x - y # z is 0.43
# Multiplication
z = x * y # z is 8.5094
# Division
z = x / y # z is 1.16230366492
#Complex
#A complex number is a number with a real and imaginary part, such as 3 + 4j. You can create a complex number by using the complex() function:
x = complex(3, 4)
#You can perform arithmetic operations with complex numbers, just like with integers and floats:
x = 3 + 4j
y = 2 + 3j
# Addition
z = x + y # z is (5+7j)
# Subtraction
z = x
# https://youtube.com/@codewithmuh
# https://github.com/rashiddaha