-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from jetbrains-academy/konstantin/modules_fee…
…dback_improvements Improvements of Modules lesson according to feedback
- Loading branch information
Showing
21 changed files
with
123 additions
and
76 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import my_funcs | ||
|
||
my_funcs.hello_world("John") |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
type: edu | ||
custom_name: Import module | ||
files: | ||
- name: imports.py | ||
visible: true | ||
placeholders: | ||
- offset: 26 | ||
length: 19 | ||
placeholder_text: '# call the hello_world function from the my_funcs module' | ||
- name: my_funcs.py | ||
visible: true | ||
- name: tests/__init__.py | ||
visible: false | ||
- name: tests/test_task.py | ||
visible: false | ||
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSfRlDlldKfuq-cHMNFfHMER61P1PRIan7KG6yp1GvaweDI7GA/viewform?usp=pp_url&entry.2103429047=Modules+and+Packages+/+Import+module |
File renamed without changes.
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import unittest | ||
import contextlib | ||
import io | ||
import re | ||
|
||
f = io.StringIO() | ||
try: | ||
with contextlib.redirect_stdout(f): | ||
from imports import * | ||
output = f.getvalue().split('\n') | ||
|
||
class TestCase(unittest.TestCase): | ||
def test_out(self): | ||
expected, actual = 'Hello, World! My name is John', output[0] | ||
self.assertEqual(expected, actual, msg='Call hello_world with the "John" argument.') | ||
|
||
except AttributeError: | ||
class TestFailCase(unittest.TestCase): | ||
def test_fail(self): | ||
self.assertTrue(False, msg='You need to use the hello_world function from the my_funcs module.') |
Empty file.
File renamed without changes.
4 changes: 0 additions & 4 deletions
4
...les and packages/Import module/imports.py → ...ackages/Import_module_part_two/imports.py
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
24 changes: 24 additions & 0 deletions
24
Modules and packages/Import_module_part_two/task-info.yaml
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
type: edu | ||
custom_name: Import module part 2 | ||
files: | ||
- name: imports.py | ||
visible: true | ||
placeholders: | ||
- offset: 0 | ||
length: 17 | ||
placeholder_text: '# Import the `calculator` module here' | ||
- offset: 26 | ||
length: 23 | ||
placeholder_text: '#Create a new instance of the `Calculator` class defined in the `calculator` module' | ||
- offset: 75 | ||
length: 11 | ||
placeholder_text: '# Use the Calculator method `add` to add `i` to the current value.' | ||
- name: calculator.py | ||
visible: true | ||
- name: tests/test_task.py | ||
visible: false | ||
- name: __init__.py | ||
visible: false | ||
- name: tests/__init__.py | ||
visible: false | ||
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSfRlDlldKfuq-cHMNFfHMER61P1PRIan7KG6yp1GvaweDI7GA/viewform?usp=pp_url&entry.2103429047=Modules+and+Packages+/+Import+module+2 |
1 change: 1 addition & 0 deletions
1
Modules and packages/Import_module_part_two/task-remote-info.yaml
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
id: 1396640314 |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## Import module 2 | ||
|
||
You can import not only functions but also classes and even other modules. It is customary, though not required, to place all | ||
import statements at the beginning of a module. | ||
|
||
You can learn more about modules in Python by reading [this section](https://docs.python.org/3/tutorial/modules.html) of The Python Tutorial. | ||
|
||
### Task | ||
In the code editor, import the `calculator` module and create an instance of the `Calculator` class (`calc`). | ||
Use the `add` method defined in `Calculator` in a loop to add up numbers from 0 to 99. | ||
|
||
<div class='hint'>Use the <code>import</code> keyword and the <code>calculator</code> reference.</div> | ||
<div class='hint'>Access the function from the module using syntax such as <code>module.function()</code>.</div> | ||
<div class="hint">Don't forget to provide the function with an argument.</div> | ||
|
Empty file.
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,30 +1,30 @@ | ||
type: edu | ||
files: | ||
- name: packages.py | ||
visible: true | ||
placeholders: | ||
- offset: 95 | ||
length: 46 | ||
placeholder_text: '# Import the `official` module here' | ||
- offset: 197 | ||
length: 20 | ||
placeholder_text: '''Say goodbye to Alex''' | ||
- name: functions/greeting/hello.py | ||
visible: true | ||
- name: functions/goodbye.py | ||
visible: true | ||
- name: classes/calculator.py | ||
visible: true | ||
- name: classes/__init__.py | ||
visible: true | ||
- name: functions/__init__.py | ||
visible: true | ||
- name: functions/greeting/__init__.py | ||
visible: true | ||
- name: functions/greeting/official.py | ||
visible: true | ||
- name: tests/__init__.py | ||
visible: false | ||
- name: tests/test_task.py | ||
visible: false | ||
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSfRlDlldKfuq-cHMNFfHMER61P1PRIan7KG6yp1GvaweDI7GA/viewform?usp=pp_url&entry.2103429047=Modules+and+Packages+/+Packages | ||
- name: packages.py | ||
visible: true | ||
placeholders: | ||
- offset: 95 | ||
length: 46 | ||
placeholder_text: '# Import the `official` module here' | ||
- offset: 197 | ||
length: 20 | ||
placeholder_text: '''Say goodbye to Alex''' | ||
- name: functions/greeting/hello.py | ||
visible: true | ||
- name: functions/goodbye.py | ||
visible: true | ||
- name: classes/calculator.py | ||
visible: true | ||
- name: classes/__init__.py | ||
visible: true | ||
- name: functions/__init__.py | ||
visible: true | ||
- name: functions/greeting/__init__.py | ||
visible: true | ||
- name: functions/greeting/official.py | ||
visible: true | ||
- name: tests/__init__.py | ||
visible: false | ||
- name: tests/test_task.py | ||
visible: false | ||
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSfRlDlldKfuq-cHMNFfHMER61P1PRIan7KG6yp1GvaweDI7GA/viewform?usp=pp_url&entry.2103429047=Modules+and+Packages+/+Packages |
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,6 +1,7 @@ | ||
content: | ||
- Import module | ||
- Built-in modules | ||
- From import | ||
- Packages | ||
- Executing modules as scripts | ||
- Import_module | ||
- Import_module_part_two | ||
- Built-in modules | ||
- From import | ||
- Packages | ||
- Executing modules as scripts |