יסודות התכנות
✦ בנוי על ידי פהד גאנם ✦
العربية
☀ מצב בהיר
1
▾
✕
print("A", "B", 7) = A B 7 | "3" + "4" = "34" | 3 + 4 = 7 | print(10 / 4) =
10
4
= 2.5
3
—
0
0
—
if x > 3
output = ""
"..." + x
output = "מתחילים\n"
print(10 / 4)
10
4
= 2.5 print(10 / 2)
10
2
= 5.0
2
▾
✕
x = 17 y = 5 | x + y = 22 | x − y = 12 | x·y = 85 |
x
y
= 3.4 | ⌊
x
y
⌋ = 3 | x − y·⌊
x
y
⌋ = 2 | x² = 289
a ** b > −a > a · b ⌊ ⌋ mod > a + b
3
0
—
—
0
x + y = 22 ; x − y = 12 ; x·y = 85
17
5
= 3.4
⌊
17
5
⌋ = 3 ; ⌊
−7
2
⌋ = ⌊−3.5⌋ = −4
17 − 5·3 = 2 ; −7 − 3·⌊
−7
3
⌋ = −7 − 3·(−3) = 2
x² = 289 ;
20
4
= 5.0
3
▾
✕
== != < > <= >= | False and B = False | True or B = True | not True = False | avg =
88 + 71 + 96
3
=
255
3
= 85.0
3
—
0
—
0
avg =
88 + 71 + 96
3
=
255
3
= 85.0
85.0 >= 90 = False
85.0 >= 80 = True
85.0 > 80 = True and 71 >= 70 = True = True
78.0 > 80 = False and ( ? ) = False
4
▾
✕
S = 1 + 2 + … + n =
n·(n + 1)
2
| n = 100 : S =
100·101
2
= 5050 | N( range(a, b, c) ) = ⌈
b − a
c
⌉ | total = total + x
4
0
—
—
0
total = 0 ; n = 1
while n <= 100:
total += n ; n += 1
for n in range(1, 101): N =
101 − 1
1
= 100
S =
n·(n + 1)
2
=
100·101
2
=
10100
2
= 5050
5
▾
✕
s[i] = s[i − len(s)] | s[a:b:c] | N( s[a:b:c] ) = ⌈
b − a
c
⌉ | s[::−1] | len( s + t ) = len(s) + len(t)
0
5
1
4
0
0
—
—
0
len(s) = 11 ; s[0] = 'E' ; s[10] = s[-1] = 'S'
N = ⌈
9 − 2
3
⌉ = ⌈
7
3
⌉ = 3 s[2:9:3] = 'ERI'
N = ⌈
10 − 1
2
⌉ = ⌈
9
2
⌉ = 5 s[1:10:2] = 'LCRNC'
−4 + 11 = 7 s[-4:] = s[7:11] = 'NICS'
s[::-1] = 'SCINORTCELE' ; len(s[::-1]) = len(s) = 11
6
▾
✕
len(a) = n | 0 ≤ i ≤ n − 1 | a[−k] = a[n − k] | avg =
sum(a)
len(a)
=
112
5
= 22.4
3
0
0
0
0
—
0
b = a ; b.append(16) ; a = b = [4, 8, 15, 16]
c = a.copy() ; c.insert(0, 1) ; c = [1, 4, 8, 15, 16]
a.pop(1) ; a = b = [4, 15, 16] ; len = 3, 3, 5
sum(c)
len(c)
=
44
5
= 8.8
stock["r"] = 9 ; stock["l"] = 1 ; len(stock) = 3
7
▾
✕
def f(a, b = 2): … return v | fact(n) = n · fact(n − 1) , fact(1) = 1 | average(a, b, c) =
a + b + c
3
| fact(4) = 24
4
0
—
—
0
0
def average(a, b, c): ; def fact(n):
average(4, 9, 8) =
4 + 9 + 8
3
=
21
3
= 7.0
n = 4 ; n = 3 ; n = 2 ; n = 1
1 ; 2 · 1 = 2 ; 3 · 2 = 6 ; 4 · 6 = 24
a = show(5) print(a) None
8
▾
✕
class Resistor : __init__(self, name, ohm) | r1 = Resistor("R1", 220) | I =
V
R
| P = V·I =
V²
R
4
0
—
—
0
r1 = Resistor("R1", 100) ; r2 = Resistor("R2", 200)
r1.drive(0.05) ⇒ self = r1
V = I·R = 0.05 · 100 = 5.0 V
P = V·I = 5.0 · 0.05 = 0.25 W ; P =
V²
R
=
25
100
= 0.25 W
V₂ = 0.05 · 200 = 10.0 V ; P₂ = 10.0 · 0.05 = 0.5 W
9
▾
✕
N = R · C | R = len(m) | C = len(m[0]) | i = ⌊
k
C
⌋ | j = k − i·C | avg =
m[i][0] + m[i][1] + … + m[i][C−1]
C
3
1.5
0
0
—
0
R = len(m) = 3 ; C = len(m[0]) = 4 ; N = R · C = 12
m[1] = [5, 6, 5, 5]
m[1][2] = 5
m[2] = [24, 23, 24, 25] ; m[2][1] = 23
avg =
5 + 6 + 5 + 5
4
=
21
4
= 5.25
10
▾
✕
t
bit
=
1
baud
| t
char
=
10 bit
baud
| baud = 9600 : t
char
=
10
9600
s = 1.042 ms |
9600
10
= 960 char/s
9600
9600
4
0
0
0
—
—
0
first = port.readline() ; peak = float(first) ; total = peak ; count = 1
while port.available() > 0:
if len(line) == 0: ... else: t = float(line) ; total += t ; if t > peak: peak = t
avg =
total
count
=
248.4
10
= 24.84
248.39999999999998 ;
248.39999999999998
10
= 24.839999999999996 ; round(avg, 2) = 24.84
→
🏠
♿