0% found this document useful (0 votes)
24 views

Introduction To Programming

The document discusses an introduction to programming over six lessons: basics of algorithms and Python, algorithm complexity, data structures and their implementation in Python, advanced Python concepts, algorithm solving techniques, and technical interview preparation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Introduction To Programming

The document discusses an introduction to programming over six lessons: basics of algorithms and Python, algorithm complexity, data structures and their implementation in Python, advanced Python concepts, algorithm solving techniques, and technical interview preparation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

‫‪Abstract‬‬

‫ﻓﻲ ھذا اﻟﻔﺻل ﺳوف ﻧﺳﺗﻌرض اﻟﻣواﺿﯾﻊ اﻟﺗﺎﻟﯾﺔ‪:‬‬

‫اﻟﺣﺻﺔ اﻷوﻟﻰ‪ :‬ﻣﻘدﻣﺔ ﻓﻲ اﻟﺧوارزﻣﯾﺎت وأﺳﺎﺳﯾﺎت اﻟﺑرﻣﺟﺔ‪ .‬ﻧﺑدأ أﯾﺿًﺎ ﺑﺄﺳﺎﺳﯾﺎت ‪ Python‬وﻧﻧﺷﺊ أول ﺧوارزﻣﯾﺔ ﻟدﯾﻧﺎ‪.‬‬

‫اﻟﺣﺻﺔ اﻟﺛﺎﻧﯾﺔ‪ :‬ﻛﯾف ﺗﻘﺎرن ﺑﯾن اﻟﺧوارزﻣﯾﺎت وﺗﻌﻘﯾدھﺎ‪ .‬ﻧﺑدأ ﺑﮭﯾﺎﻛل ﺑﯾﺎﻧﺎت ﺑﺳﯾطﺔ‪(Complexity in big O notation) .‬‬

‫اﻟﺣﺻﺔ اﻟﺛﺎﻟﺛﺔ‪ :‬اﻻﺳﺗﻣرار ﻓﻲ ھﯾﺎﻛل اﻟﺑﯾﺎﻧﺎت وﺗﻧﻔﯾذھﺎ‪(Data structures and their implementation):‬‬

‫اﻟﺣﺻﺔ اﻟراﺑﻌﺔ‪ :‬ﻣﻔﺎھﯾم ﻣﺗﻘدﻣﺔ ﻓﻲ ‪ Python‬ﻣﺛل‪List comprehension, unpacking, lambda functions :‬‬

‫اﻟﺣﺻﺔ اﻟﺧﺎﻣﺳﺔ‪ :‬ﻣﺧﺗﻠف اﻟطرق ﻓﻲ ﺣل اﻟﺧوارزﻣﯾﺎت‪(Algorithm solving technique).‬‬

‫اﻟﺣﺻﺔ اﻟﺳﺎدﺳﺔ‪ :‬إﻋداد ﻣﻘﺎﺑﻠﺔ ﻓﻲ ﺣل اﻟﻣﺷﻛﻼت‪(Technical Interview preparation).‬‬


‫ﻣﺪﺧﻞ إﻟﻰ اﻟﺒﺮﻣﺠﺔ‬

‫‪27/03/2020‬‬ ‫ﺣﻤﺰة ﺑﻮرﺑﻮح‬


‫أﻳﻮب ﻛﺸﻜﺎش‬
‫ﻋﻼش ﺗﻌﻠﻢ اﻟﺒﺮﻣﺠﺔ؟‬
‫● ﺣﯾﺎﺗﻧﺎ ﻣﺣﺎطﺔ ﺑﺎﻟﺗﻛﻧوﻟوﺟﯾﺎ‪ :‬ﻛﯾف ﺗﻛون ﺻﺎﻧﻊ ﻟﻠﺗﻛﻧوﻟوﺟﯾﺎ ﻋوض ﻣﺳﺗﮭﻠك ﻟﮭﺎ‬
‫● إذا ﻛﻧت ﻣﮭﺗﻣﺎ ﺑﺎﻟﮭﻧدﺳﺔ ﻓﻔﻲ اﻟﻐﺎﻟب ﺳﺗﺣﺗﺎج ﻟﻠﺑرﻣﺟﺔ‬
‫● ﻟﯾزادت ﻓراس ﺗﻧﻔﻊ ‪(:‬‬
‫ﻣﺎ ﻫﻲ اﻟﺒﺮﻣﺠﺔ؟‬
‫إﻋطﺎء ﺧطوات ﻋﻠﻰ ﺷﻛل ﺗﻌﻠﯾﻣﺎت )‪ (instructions‬ﻟﻠﺣﺎﺳوب ﻟﺣل ﻣﺷﻛل ﻣﺎ‪.‬‬

‫ھﺎد اﻟﺗﻌﻠﯾﻣﺎت ﺧﺎص إﺣﺗﺎرﻣو واﺣد اﻟﺗرﻛﯾﺑﺔ اﻟﻠﻐوﯾﺔ )‪ (syntax‬ﺧﺎﺻﺔ ﺑﻠﻐﺔ‬


‫اﻟﺑرﻣﺟﺔ ﻟﻲ ﻋزﻟﺗﻲ‬
‫ ﻧﻔﺲ اﻟﻨﺘﻴﺠﺔ‬، ‫ﻟﻐﺎت ﻣﺨﺘﻠﻔﺔ‬

#include <stdio.h> print(‘Salam!’) import "fmt"

int main() { func main() {


printf(“Salam!”); fmt.Println("Salam!")
} }

C Python Go
‫اﻟﺼﻌﻮﺑﺔ دﻳﺎل اﻟﺒﺮﻣﺠﺔ‬
‫أﺻﻌب ﺷﺊ ﻣﺎﺷﻲ ھو ﺗﻌﻘل ﻋﻠﻰ ‪ syntax‬دﯾﺎل ‪programming‬‬
‫‪ language‬ﻟﻠﻲ ﻛﺗﺧدم‬

‫ﺑل اﻷﺻﻌب ھو ﺗﺣط راﺳك ﺑﻼﺳت اﻟﺣﺎﺳوب دﯾﺎﻟك ﻣﻠﻲ ﺗﻛون ﻛﺗﺣﺎول ﺗﻠﻘﻰ‬
‫ﺣل‬

‫ﻣﺛﻼ ‪...‬‬
‫]‪[5, 3, 12, 10, 27, 9, 15‬‬ ‫أﻛﺒﺮ ﻋﺪد‬
‫‪Variable‬‬
‫ﻣﺗﻐﯾر‬
‫‪ .1‬ﻟﻧﻌﺗﺑر أول ﻋدد ھو أﻛﺑر ﻋدد‪ .‬ﻧﺳﻣﻲ ھذا اﻟﻌدد ‪max‬‬

‫‪Loop‬‬
‫‪ .2‬ﻟﻛل ﻋدد ‪ x‬ﻓﻲ اﻟﻘﺎﺋﻣﺔ‪:‬‬
‫‪x → max‬‬ ‫‪ .a‬إذا ﻛﺎن ‪ x‬أﻛﺑر ﻣن ‪:max‬‬
‫ﻋﻘدة‬ ‫‪Condition‬‬
‫ﺷرط‬

‫‪ .3‬أﻛﺑر ﻋدد ھو ‪max‬‬


‫أﻛﺒﺮ ﻋﺪد‬
l = [5, 3, 12, 10, 27, 9, 15]

1. max_num = l[0]
2. for x in l:
3. if x > max_num:
max_num = x

4. print(max_num)
(variables) ‫اﻟﻤﺘﻐﻴﺮات‬
a = 2 2
a 3
a = 3.2 3.2
a = a + 1 b
4.2
b = a
b = 8 8

Memory representation
Code ‫ﺗﻤﺜﻴﻞ اﻟﺬاﻛﺮة‬
(variables) ‫اﻟﻤﺘﻐﻴﺮات‬
a = [11, 12, 3] [11, 12, 3]
a 3
a = ‘salam’ ‘salam’
a = a + ‘ qalam’ b
‘salam qalam’
b = a
b = [99] + [3, 6] [99, 3, 6]

Memory representation
Code ‫ﺗﻤﺜﻴﻞ اﻟﺬاﻛﺮة‬
(variables) ‫اﻟﻤﺘﻐﻴﺮات‬
a = [11, 12] [11,12,
[11, 12]3]
a
b = a
a.append(3) # mutates b [11, 12, 3, 10]

b = b + [10] # doesn’t

Memory representation
Code ‫ﺗﻤﺜﻴﻞ اﻟﺬاﻛﺮة‬
Input/Output ‫اﻟﺘﻮاﺻﻞ ﻣﻊ اﻟﻤﺴﺘﻌﻤﻞ‬
name = input(“Please enter your name”)

grade = input(“Please enter your age”)

print(f“{name} is {age} years old.”)


Conditions ‫اﻟﺸﺮوط‬
if <condition1>:
# do something
elif <condition2>:
# do other thing
elif <condition3>:
# do other thing
...
else:
# do something
‫ﺗﻤﺮﻳﻦ ﺗﻄﺒﻘﻲ ‪1‬‬
‫اﻛﺗب ﺑرﻧﺎﻣﺞ ﯾﺗﻠﻘﻰ إﺳم و ﻧﻘطﺔ ﺗﻠﻣﯾذ ﯾﻌطﻲ اﻟﻧﻘطﺔ ﻋﻠﻰ ﺷﻛل ﺣرف‪.‬‬

‫‪A = 100-90‬‬
‫‪B = 90-80‬‬
‫‪C = 70-80‬‬
‫‪F = 70-0‬‬
Loops ‫اﻟﻌﻘﺪة‬
for <var> in <sequence>: while <condition>:
# do smthg
# do smthg

----
for <var> in range(start, end, step):
# do smthg
‫ﺗﻤﺮﻳﻦ ﺗﻄﺒﻘﻲ ‪2‬‬
‫اﻛﺗب ﺑرﻧﺎﻣﺞ ﯾﺗﻠﻘﻰ ﻋدد اﻟﺗﻼﻣﯾذ و ﻧﻘطﮭم و ﯾﻌطﻲ أﻋﻠﻰ و أدﻧﻰ ﻧﻘطﺔ‪.‬‬
‫ﺗﻤﺮﻳﻦ ﺗﻄﺒﻘﻲ ‪3‬‬
‫اﻛﺗب ﺑرﻧﺎﻣﺞ ﯾﺗﻠﻘﻰ ﻧﻘط اﻟﺗﻼﻣﯾذ و ﻛﯾﻌطﻲ إﺣﺻﺎﺋﯾﺎت ﻋﻠﻰ ھﺎد اﻟﻧﻘط‪.‬‬
4 ‫ﺗﻤﺮﻳﻦ ﺗﻄﺒﻘﻲ‬
Guess the output.
Functions ‫اﻟﺪوال‬
# FUNCTION DEFINITION
# ‫ﺗﻌﺮﻳﻒ اﻟﺪاﻟﺔ‬
def add(x, y): x=a
# do smthg y=b
result 5
return x + y

x a 1
# FUNCTION CALL
# ‫اﺳﺘﺪﻋﺎء داﻟﺔ‬
a = 1 y b 4
b = 4
result = add(a, b)
add

Global
Functions ‫اﻟﺪوال‬
def incr(x):
x = x + 1

a = 2
incr(a)

print(a) # output: 2 x a 2

incr

Global
Functions ‫اﻟﺪوال‬
def incr(x):
x = x + 1

x = 2
incr(x)

print(x) # output: 2 x x 2

incr

Global
Functions ‫اﻟﺪوال‬
def add_four(l):
l.append(4)

lst = [0, 3]
add_four(lst)
lst
print(lst) l [0, 3,
3] 4]

incr

Global
‫ﺗﻤﺮﻳﻦ ﺗﻄﺒﻘﻲ ‪5‬‬
‫اﻛﺗب ﺑرﻧﺎﻣﺞ ﻛﯾﺗﻌطﺎه ﻧﻘط‪ ،‬أﺳﻣﺎء و رﻗم ھوﯾﺔ ﺗﻼﻣﯾذ و ﻛﯾﻌطﯾك ﺑﯾﺎﻧﺎت‬
‫اﻟﺗﻼﻣﯾذ اﻟﻠﻲ ﺳﻘطو اﻷﻣﺗﺣﺎن‬
Classes and Objects
class Human: def __init__(self, name, age):
def __init__(self, name, age):
self.age = age
self
self.name = name self self self
age =
4
age = 42 age = 42 name 2
def present(self, f_name): name = ‘Ali’ = ‘Ali’

return f’Salam {f_name}!


Ana {self.name}.’

h1 = Human(‘Ali’, 42)
h1.present(‘Ayoub’)
# output:
# ‘Salam Ayoub! Ana Ali.
Python ‫ﻣراﺟﻊ ﻟﺗﻌﻠم‬

● Automate the Boring Stuff with Python:


https://automatetheboringstuff.com
● Python Programming Tutorials (Socratica channel):
https://www.youtube.com/playlist?list=PLi01XoE8jYohWFPpC17Z-w
WhPOSuh8Er-
● Python official Tutorials: https://docs.python.org/3/tutorial/
● RealPython channel:
https://www.youtube.com/channel/UCI0vQvr9aFn27yR6Ej6n5UA
‫ﺷﻜﺮ َا‬
‫داﺑﺎ وﻗﺖ اﻷﺳﺌﻠﺔ و اﻟﺒﻠﺒﻠﺔ‬

You might also like