Skip to content

Commit 4c96336

Browse files
committedDec 20, 2023
Add changes to Modules and packages lesson
1 parent 2914d21 commit 4c96336

File tree

8 files changed

+38
-25
lines changed

8 files changed

+38
-25
lines changed
 

Diff for: ‎Modules and packages/Built-in modules/task.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ for modules: see what it prints for you when you run the code of the task.
2222

2323
Remember that you can use &shortcut:CodeCompletion; after a dot (.) to explore available
2424
methods of a module. You can read more about standard modules <a href="https://docs.python.org/3/tutorial/modules.html#standard-modules">here</a>.
25-
25+
26+
For more structured and detailed information, you can also refer to [this Hyperskill knowledge base page](https://hyperskill.org/learn/step/6019#built-in-modules).
27+
28+
### Task
2629
Print the current date and time using an imported built-in module `datetime`.
2730

2831
<div class='hint'>Use the <code>datetime.datetime.today()</code> function.</div>

Diff for: ‎Modules and packages/Executing modules as scripts/some_module.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def func():
44

55
print(f'This is a message from {__name__}.')
66

7-
# Make a change here (add a main block!)
7+
# Make a change here (add a main block)
88
if __name__ == "__main__":
99
print('This should not be printed')
1010

Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
type: edu
22
files:
3-
- name: task.py
4-
visible: true
5-
placeholders:
6-
- offset: 65
7-
length: 18
8-
placeholder_text: '# Call func() from the imported module'
9-
- offset: 107
10-
length: 100
11-
placeholder_text: print('This should be printed ONLY when dict_keys.py is called
12-
directly.')
13-
- name: tests/test_task.py
14-
visible: false
15-
- name: __init__.py
16-
visible: false
17-
- name: tests/__init__.py
18-
visible: false
19-
- name: some_module.py
20-
visible: true
21-
placeholders:
22-
- offset: 174
23-
length: 66
24-
placeholder_text: print('This should not be printed')
3+
- name: task.py
4+
visible: true
5+
placeholders:
6+
- offset: 65
7+
length: 18
8+
placeholder_text: '# Call func() from the imported module'
9+
- offset: 125
10+
length: 100
11+
placeholder_text: print('This should be printed ONLY when task.py is called directly.')
12+
- name: tests/test_task.py
13+
visible: false
14+
- name: __init__.py
15+
visible: false
16+
- name: tests/__init__.py
17+
visible: false
18+
- name: some_module.py
19+
visible: true
20+
placeholders:
21+
- offset: 173
22+
length: 66
23+
placeholder_text: print('This should not be printed when this file is imported')
2524
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSfRlDlldKfuq-cHMNFfHMER61P1PRIan7KG6yp1GvaweDI7GA/viewform?usp=pp_url&entry.2103429047=Modules+and+Packages+/+Executing+modules+as+scripts

Diff for: ‎Modules and packages/Executing modules as scripts/task.md

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ some_module __name__ is: __main__
5656
some_module executed directly
5757
```
5858

59+
For more structured and detailed information, you can refer to [this Hyperskill knowledge base page](https://hyperskill.org/learn/step/6057).
60+
5961
### Task
6062
<i>The files in this task are named the same as in the examples above, but their code is a bit different.</i>
6163

Diff for: ‎Modules and packages/Executing modules as scripts/task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
print(f'This is a message from {__name__}.')
44
some_module.func()
55

6-
# Make a change here.
6+
# Make a change here (add a main block)
77
if __name__ == "__main__":
88
print('This should be printed ONLY when task.py is called directly.')
99

Diff for: ‎Modules and packages/From import/task.md

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ when utilising `from` with similar effects:
3737
from calculator import Subtract as Minus
3838
```
3939

40+
For more structured and detailed information, you can refer to [this Hyperskill knowledge base page](https://hyperskill.org/learn/step/6019#module-loading).
41+
42+
### Task
4043
Import the `Calculator` class from `calculator` and create an instance of this class. Remember how to access it correctly in
4144
this case.
4245

Diff for: ‎Modules and packages/Import module/task.md

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import statements at the beginning of a module.
2222

2323
You can find out more about modules in Python by reading [this section](https://docs.python.org/3/tutorial/modules.html) of The Python Tutorial.
2424

25+
For more structured and detailed information, you can also refer to [this Hyperskill knowledge base page](https://hyperskill.org/learn/step/6019#module-loading).
26+
27+
### Task
2528
In the code editor, import the module `calculator` and create an instance of the class `Calculator` (`calc`).
2629
Use the `add` method defined in `Calculator` in a loop to add up numbers from 0 to 99.
2730

Diff for: ‎Modules and packages/Packages/task.md

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ hello.hello('Susan')
4040

4141
You can learn more about packages by reading <a href="https://docs.python.org/3/tutorial/modules.html#packages">this page</a> of Python Documentation.
4242

43+
For more structured and detailed information, you can also refer to [this Hyperskill knowledge base page](https://hyperskill.org/learn/step/6384).
44+
45+
### Task
4346
In the code editor, import the `official` module properly to make the last `print`
4447
statement work.
4548

0 commit comments

Comments
 (0)
Please sign in to comment.