1. LAB 1- INTRODUCTION TO PYTHON
PROGRAMMING LANGUAGE
Eng. Ahmed S. Alsayadi
Winter-2020
Sana’a University
Faculty of Engineering
Mechatronics Engineering Department
Mechatronics System Design Practical Lab
Mechatronics System Design(2) MT503
5th Level
3. >> np.array([])
#create an array of given values
>> np.empty(Shape, data type)
#create an array of random values
>> np.zeros(Shape, data type)
#create an array of zero values
>> np.eye(row, column)
#create an array of ones-in-diagonal and zeros else where
Creating Arrays
4. >> np.arange(X).reshape(row, column)
#an array of 0 to X with a specific shape
>> np.arange(start, stop, increment)
#an array starts from – to – with an increment
>> np.flatten()
#convert an array into one row
Reshaping Arrays
8. import numpy as np
x = np.random.randint(0, 10, 40)
print("Original array:")
print(x)
print("Most frequent value in the above array:")
print(np.bincount(x).argmax())
Most frequent value in an array
13. Eng. Ahmed S. Alsayadi
777 278 525
For the next lab
• Review operations with numpay arrays
• Prepare for a simple understanding check ”quiz”
• Material related
• Numpy documentation