יסודות התכנות

✦ בנוי על ידי פהד גאנם ✦

print("A", "B", 7) = A B 7   |   "3" + "4" = "34"   |   3 + 4 = 7   |   print(10 / 4) = 104 = 2.5
3
0
0

if x > 3
output = ""
"..." + x
output = "מתחילים\n"
print(10 / 4)    104 = 2.5    print(10 / 2)    102 = 5.0

x = 17   y = 5   |   x + y = 22   |   x − y = 12   |   x·y = 85   |   xy = 3.4   |   ⌊xy⌋ = 3   |   x − y·⌊xy⌋ = 2   |   x² = 289
a ** b  >  −a  >  a · b   ⌊ ⌋   mod  >  a + b
3
0
0

x + y = 22   ;   x − y = 12   ;   x·y = 85
175 = 3.4
175⌋ = 3   ;   ⌊−72⌋ = ⌊−3.5⌋ = −4
17 − 5·3 = 2   ;   −7 − 3·⌊−73⌋ = −7 − 3·(−3) = 2
x² = 289   ;   204 = 5.0

==   !=   <   >   <=   >=   |   False and B = False   |   True or B = True   |   not True = False   |   avg = 88 + 71 + 963 = 2553 = 85.0
3
0
0

avg = 88 + 71 + 963 = 2553 = 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

S = 1 + 2 + … + n = n·(n + 1)2   |   n = 100 : S = 100·1012 = 5050   |   N( range(a, b, c) ) = ⌈ b − ac ⌉   |   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 − 11 = 100
S = n·(n + 1)2 = 100·1012 = 101002 = 5050

s[i]  =  s[i − len(s)]   |   s[a:b:c]   |   N( s[a:b:c] ) = ⌈ b − ac ⌉   |   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 − 23 ⌉ = ⌈ 73 ⌉ = 3    s[2:9:3] = 'ERI'
N = ⌈ 10 − 12 ⌉ = ⌈ 92 ⌉ = 5    s[1:10:2] = 'LCRNC'
−4 + 11 = 7    s[-4:] = s[7:11] = 'NICS'
s[::-1] = 'SCINORTCELE'   ;   len(s[::-1]) = len(s) = 11

len(a) = n   |   0 ≤ i ≤ n − 1   |   a[−k] = a[n − k]   |   avg = sum(a)len(a) = 1125 = 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) = 445 = 8.8
stock["r"] = 9   ;   stock["l"] = 1   ;   len(stock) = 3

def f(a, b = 2): … return v   |   fact(n) = n · fact(n − 1) , fact(1) = 1   |   average(a, b, c) = a + b + c3   |   fact(4) = 24
4
0
0
0

def average(a, b, c):   ;   def fact(n):
average(4, 9, 8) = 4 + 9 + 83 = 213 = 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

class Resistor :    __init__(self, name, ohm)   |   r1 = Resistor("R1", 220)   |   I = VR   |   P = V·I = 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 = R = 25100 = 0.25 W
V₂ = 0.05 · 200 = 10.0 V   ;   P₂ = 10.0 · 0.05 = 0.5 W

N = R · C   |   R = len(m)   |   C = len(m[0])   |   i = ⌊ kC ⌋   |   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 + 54 = 214 = 5.25

tbit = 1baud   |   tchar = 10 bitbaud   |   baud = 9600 : tchar = 109600 s = 1.042 ms   |   960010 = 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 = totalcount = 248.410 = 24.84
248.39999999999998   ;   248.3999999999999810 = 24.839999999999996   ;   round(avg, 2) = 24.84
🏠