SamiTech Code
339 subscribers
124 photos
12 videos
4 files
83 links
Computer Science student and software developer focused on building impactful products, exploring AI, and solving real-world challenges with technology.
My portfolio.... sami.pro.et

“Your efforts today are your goals tomorrow.”
Download Telegram
What is Numpy:
-NumPy is a Python library.
-NumPy is used for working with arrays.
-NumPy is short for "Numerical Python".
👍2
Why Use NumPy?
In Python we have lists that serve the purpose of arrays, but they are slow to process.
The array object in NumPy is called ndarray, it provides a lot of supporting functions that make working with ndarray very easy.
Arrays are very frequently used in data science & also ML, where speed and resources are very important.
Why is NumPy Faster Than Lists?
NumPy arrays are stored at one continuous place in memory unlike lists, so processes can access and manipulate them very efficiently.
This behavior is called locality of reference in computer science.
This is the main reason why NumPy is faster than lists. Also it is optimized to work with latest CPU architectures
What does Numpy stands for?
Anonymous Quiz
0%
Number picker
0%
Numerical platform
100%
Numerical python
How to import numpy:👇
import numpy
arr = numpy.array([1,2,3,4,5])
print(arr)

don't forget to use array keyword👉🏽 numpy.array
We use NumPy instead of Python lists for numerical and scientific computing primarily because NumPy arrays offer superior performance, memory efficiency,
and a rich set of mathematical functions.
#NumPy as np
#NumPy is usually imported under the np alias

import numpy as np
arr = np.array([1,2,3,4,5])
print(arr)


#Therefore, Now the NumPy package can be referred to as np instead of numpy. We've to keep in mind it👀
Check number of dimensions:👇
import numpy as np

a = np.array(42)
b = np.array([1, 2, 3, 4, 5])
c = np.array([[1, 2, 3], [4, 5, 6]])
d = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])

#how many dimension appear in each line
print(a.ndim) #0
print(b.ndim) #1
print(c.ndim) #2
print(d.ndim) #3
Consider the following array:
arr = np.array([[1, 2, 3], [4, 5, 6]])
How many dimensions does it have?
Anonymous Quiz
88%
2
13%
3
0%
1
We've covered NumPy creating Arrays🎉🎉🎉 Now we gonna look at NumPy Array indexing: =>Access Array elements =>Access 2-D =>Access 3-D =>Negative indexing Finally, with a easy questions 🫡 But if you've questions feel free to write in the comment sections
1
#Access array element
import numpy as np
num = np.array([2, 4, 5, 7])

print(num[0]) #access the first element:2
print(num[2] + num[3]) #Summation: 12


#Access 2-D array
import numpy as np
num = np.array([[2, 3, 4], [5, 1, 6]])
print(num[1, 2]) #3rd element on 2nd row so 6


#Access 3-D array
import numpy as np
num = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]])
print(num[0, 0, 1]) #2


#Negative indexing
import numpy as np
num = np.array([[2, 4, 1], [3, 5, 6]])
print(num[1, -1]) #6

I'll give the deep clarifications on the 3-D cause it might be small trick😦
2
Guys sorry this night just I've decided to have some rest. & It's hard to study. Cause I got bad cough😒😮‍💨
🫡1
Morning buddies🎉
I've pinned the message so in todays we gonna focus on DSA. You know that we were learning some types of sorting techniques. we stopped on merge sort. now let's begin it 👉🏽QUICK SORT on learning.... be with me🙏
Here I take this example then try to do with quick sort: Look at it👇👇👇👇
[3, -2, -1, 0, 2, 4, 1]
at the first i take
pivot 1:
3 > 1, -2 < 1, -1 < 1, 0 < 1, 2 > 1, 4 > 1
then elements smaller that 1 are -2, -1, 0
elements greater than 1 are 3, 2, 4
and then [-2,-1,0] 1 [3, 2, 4]

now what i've to do is to arrange elements smaller than 1 as a pivot take 0
pivot 0: -2 < 0, -1 < 0 They're ordered
Know elements up to 1 are ordered:[-2, -1, 0, 1]
the next is to sort elements right of 1: those are [3, 2, 4]
as a pivot take 4:
3 < 4, 2 < 4 : [3, 2] 4 []
and know take 2 as a pivot: 3 > 2: then [] 2 [3]
combine the process right of 1: ->>[2, 3, 4] Done
now combine the elements left of 1: [-2, -1, 0, 1]

COMBINE ALL OF THEM: [-2, -1, 0, 1, 2, 3, 4] done
I understand in this way

""""
compare numbers with pivot
group them
sort left
sort right
combine

Average time: O(n log n)
""""

In the next I'll do the implementations part. I was just try to understand this concept. Now I understand the trick, we use in Quick sort technique. 🎉🎉🎉
Good Morning guys
Have a nice sunday😄
How are you all🤝
I know that, I didn't share for u some topics in this channel.
I was busy with class.
Whatever no worries, am gonna arrange it.⚡️
Hey at this night am about to work on some project.
So stay tuned, And tommorow we'll keep learn numpy from where we stoped 👌