☰ Year plan · Communication Technology (Arabic)

القوائم والدوال

Week 12 · Chapter 12 Programming (2): lists and functions in Python, with small programs that combine them · 3 lessons
الإجابات لأولياء الأمور والمعلمين.
1
⁦scores = [3, 9, 4]⁩. اكتب نتيجة ⁦scores[0]⁩ و⁦scores[2]⁩ و⁦len(scores)⁩ و⁦scores[-1]⁩.
2
تتبع هذا البرنامج في جدول واكتب ما يطبعه.
Python
1scores = [3, 9, 4]
2best = scores[0]
3for x in scores:
4    if x > best:
5        best = x
6print(best)
3
اكتب دالة ⁦cube(n)⁩ تعيد ⁦n * n * n⁩، واكتب قيمة ⁦cube(3)⁩.
4
اكتب ما يطبعه هذا البرنامج، واشرح لماذا يعرض السطر الثاني ⁦None⁩.
Python
1def show(n):
2    print(n * n)
3
4r = show(5)
5print(r)
5
في برنامج ⁦passed⁩ غيّر درجة النجاح إلى ٦٠. كم درجة من ⁦[45, 72, 50, 38, 90]⁩ تنجح الآن؟