-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetic_Operations.html
More file actions
120 lines (104 loc) · 2.85 KB
/
Arithmetic_Operations.html
File metadata and controls
120 lines (104 loc) · 2.85 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Append List Example</title>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css">
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
<h1>Append Items to a List in Python</h1>
<py-script>
'''
---
jupyter:
jupytext:
cell_metadata_filter: -all
custom_cell_magics: kql
text_representation:
extension: .py
format_name: markdown
format_version: '1.3'
jupytext_version: 1.11.2
kernelspec:
display_name: .venv
language: python
name: python3
---
'''
import numpy as np
# create an array of 5 integers
arr = np.arange(5)
print("array1", arr)
arr2 = np.arange(5,10)
print ("array2 ",arr2)
print(" ")
print ("Addition operator: ")
a = arr+4
print(a)
print(" ")
print ("Subtraction operator: ")
s = arr-4
print(s)
print(" ")
print ("Multiplication operator: ")
m = arr+4
print(m)
print(" ")
print ("Division operator: ")
d = arr/2
print(d)
print(" ")
print ("Modulus operator: ")
md = arr%4
print(md)
print(" ")
print (" ================================ ")
print ("Arithmetic operations using multidimensional arrays: ")
print(" ")
print("Addition operator")
ai = arr+arr2
print(ai)
print(" ")
print("Subtraction operator")
ai = arr-arr2
print(ai)
print(" ")
print ("Multiplication operator: ")
mi = arr+arr2
print(mi)
print(" ")
print ("Division operator: ")
di = arr/arr2
print(d)
print(" ")
print ("Modulus operator: ")
mdi = arr%arr2
print(mdi)
print(" ")
print (" ================================ ")
print ("Arithmetic operations using sine and square root: ")
print(" ")
print ("sine operator: ")
sinarr = np.sin(arr)
print(sinarr)
print(" ")
print ("square root operator: ")
sqrtarr = np.sqrt(arr)
print(sqrtarr)
print(" ")
print (" ================================ ")
print (" Multidimentional operations: ")
Arr= np.arange(0,8).reshape(2,4)
print(Arr)
print(" ")
print ("Multidimentional array multiplied by ones: ")
Arr2= np.ones((2,4))
print(Arr2)
print(" ")
C= Arr2 * Arr
print(C)
</py-script>
</body>
</html>