forked from lubojr/naucse.python.cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
244 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
|
||
# Homework | ||
|
||
Try out these exercises at home. These are just examples. Try to find some more examples in the internet or just play around! | ||
جرب هذه التمارين في المنزل. هذه مجرد أمثلة. حاول العثور على المزيد من الأمثلة على الإنترنت أو فقط العب قليلاً! | ||
|
||
1. Which Python version are you using? | ||
2. Not everything can be used as a variable name. Which ones of these cannot be used as variable names? If you are not sure, try it out. | ||
- `x`, `button4`, `34`, `3e4`, `turkey`, `$i`, `square-root`, `readme`, `readme.txt`, `shorterEdge`, `shorter_edge`, `NUMBER_OF_POINTS`, `_`, `π`, `True`, `_cache`, `__name__`, `while`. | ||
3. Some of the names above are valid, but not very good variable names. Which ones do you think are those? | ||
4. Which one of `shorterEdge`, `shorter_edge` is a more correct name for a variable? Why? Try searching for *PEP 8 variable names*. What's a `PEP 8`? | ||
5. Try to write a program that calculates the `surface` and `volume` of a `cube` with `edge = 2852 cm`. | ||
6. Now change the program so that the user can enter the `edge` value. | ||
7. Write a program that calculates the `Body Mass Index (BMI)` from a user's `weight` and `height`. | ||
The BMI is a measure of some's weight taking into account their height. e.g. If a tall person and a short person both weigh the same amount, the short person is usually more overweight. | ||
The BMI is calculated by `dividing` a person's `weight` (in kg) by the `square of their height` (in `m`). | ||
8. Write the following code into single cell and run it more times. What is it doing? | ||
1. ما إصدار (version) Python الذي تستخدمه؟ | ||
2. لا يمكن استخدام كل شيء كاسم متغير. أي منها لا يمكن استخدامه كأسماء متغيرات؟ إذا لم تكن متأكدًا ، فجرب ذلك. | ||
- `x` ، `button4` ، `34` ، `3e4` ، `turkey` ، `$i` ، `square-root` ، `readme` ، `readme.txt` ، `shorterEdge` ، `shorter_edge` ، `NUMBER_OF_POINTS` ، `_` ، `π` ، `True` ، `_cache` ، `__name__` ، `while`. | ||
3. بعض الأسماء أعلاه صالحة ، ولكنها ليست أسماء متغيرات جيدة جدًا. أيهما تعتقد أنها تلك؟ | ||
4. أيهما من `shorterEdge` ، `shorter_edge` هو اسم متغير أكثر صحة؟ لماذا ا؟ حاول البحث عن *أسماء متغيرات PEP 8*. ما هو `PEP 8`؟ | ||
5. حاول كتابة برنامج يحسب `surface` و `volume` لـ `cube` مع `edge = 2852 cm`. | ||
6. الآن قم بتغيير البرنامج بحيث يمكن للمستخدم إدخال قيمة `edge`. | ||
7. اكتب برنامجًا يحسب **مؤشر كتلة الجسم (BMI)** من `weight` و `height` للمستخدم. | ||
مؤشر كتلة الجسم هو مقياس لوزن شخص ما مع مراعاة طوله. على سبيل المثال ، إذا كان الشخص الطويل والقصير يزن نفس الوزن ، فإن الشخص القصير يكون عادةً أكثر بدانة. | ||
يتم حساب مؤشر كتلة الجسم بقسمة وزن الشخص (بالكيلوغرام) على **مربع الطول** (بالمتر). | ||
8. اكتب الكود التالي في خلية واحدة وقم بتشغيله عدة مرات. ماذا يفعل؟ | ||
```python | ||
from random import randrange | ||
number = randrange(3) | ||
print(number) | ||
from random import randrange | ||
number = randrange(3) | ||
print(number) | ||
``` | ||
|
||
<!-- 9. Combine code above with your previous code for a game ‘rock, paper, scissors’ the way that pc_choice is: | ||
- 'rock' if number is 0 | ||
- 'scissors' if number is 1 | ||
- Else is 'paper' --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
title: Homework - lesson 2 | ||
style: md | ||
attribution: | ||
- Translated by Mussab Abdalla | ||
- Mateusz Krainski | ||
license: cc-by-sa-40 |
Oops, something went wrong.