-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Add Python Introduction, Python Basics (1-14 tasks) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kochaika
wants to merge
6
commits into
main
Choose a base branch
from
lessons-1-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
26a4db0
Add Python Introduction, Python Basics (1-14 tasks)
a3f6572
Update lesson 2
3fa7a2f
Add introduction
d2c1823
Improve the third introduction lesson
178c654
Rename lessons to shorten paths
5879626
Change lesson 2 structure and add additional files
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| if __name__ == "__main__": | ||
| # Write your solution here | ||
| pass |
This file contains hidden or 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,7 @@ | ||
| type: theory | ||
| custom_name: About | ||
| files: | ||
| - name: task.md | ||
| visible: false | ||
| - name: main.py | ||
| visible: true |
This file contains hidden or 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,14 @@ | ||
| # Welcome | ||
|
|
||
| Welcome to the **Complete Python Developer Zero to Mastery** course. | ||
|
|
||
| In this course, you will learn Python from the ground up, starting with the fundamentals and gradually moving on to more practical exercises and real working programs. Each section builds on the previous one, helping you develop both understanding and confidence as you progress. | ||
|
|
||
| In the next two tasks, you will take your first steps in the development environment. We will explore the IDE interface in more detail and run your first Python program. | ||
|
|
||
| #### Prerequisites | ||
|
|
||
| You don't need to have any previous experience in Python or programming in general | ||
| to complete this course. | ||
|
|
||
| **Click the "Next" button to navigate to the next task and good luck!** |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 @@ | ||
| if __name__ == "__main__": | ||
| # Write your solution here | ||
| pass |
This file contains hidden or 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,22 @@ | ||
| type: theory | ||
| custom_name: Navigating Around | ||
| files: | ||
| - name: task.md | ||
| visible: false | ||
| - name: main.py | ||
| visible: true | ||
| - name: images/edu_course_overview.png | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/edu_course_overview_dark.png | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/forward.svg | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/back.svg | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/reset.svg | ||
| visible: false | ||
| is_binary: true |
This file contains hidden or 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,55 @@ | ||
| ## JetBrains Academy plugin overview | ||
|
|
||
| This lesson will help you take your first steps with the [JetBrains Academy plugin](https://www.jetbrains.com/help/education/educational-products.html) and use it to learn Python. | ||
|
|
||
| With the JetBrains Academy plugin, you can learn programming languages and tools by completing coding tasks and get instant feedback right inside the IDE. | ||
|
|
||
| If you're already familiar with the interface, you can skip this lesson. | ||
|
|
||
| ### Working with courses | ||
| When you open a course, you will see the main tool windows used for navigation: <b>Course View</b>, <b>Editor</b>, and <b>Task Description</b>. | ||
|
|
||
| <style> | ||
| img { | ||
| display: block; | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| } | ||
| </style> | ||
| <img src="images/edu_course_overview.png" class="center" width=800> | ||
|
|
||
| In <b>Course View</b>, you can switch between lessons and tasks. In the <b>Editor</b>, you write code and complete the task. In <b>Task Description</b>, you can read the theory and the task instructions. | ||
|
|
||
| ### Task Description | ||
|
|
||
| The **Task Description** window gives you all the information you need to complete a task: | ||
|
|
||
| - For theoretical tasks, the description provides learning and reading materials. | ||
| - For programming assignments, it states the problem to be solved. | ||
|
|
||
| Use Task Description icons for the following actions: | ||
|
|
||
| | Icon | Description | | ||
| |------------------------------------|-------------------------------| | ||
| |**Check** | <font size="-1">Check the correctness of your answer (for a quiz) or your code solution (for a programming task)</font>| | ||
| | **Run** | <font size="-1">Run your code (for a theoretical task)</font>| | ||
| | | <font size="-1">Go to the previous task</font> | | ||
| | <font size="-1">or</font> **Next** | <font size="-1">Go to the next task</font>| | ||
| | | <font size="-1">Discard all the changes you’ve made in the task, and start over</font>| | ||
| |<a>Peek Solution...</a> | <font size="-1">Reveal the correct answer and show the <b>diff</b></font>| | ||
|
|
||
| <style> | ||
| img { | ||
| display: inline !important; | ||
| } | ||
| table, th, td { | ||
| border: 1px solid black; | ||
| border-collapse: collapse; | ||
| } | ||
| th, td { | ||
| padding: 5px; | ||
| } | ||
| table td:nth-child(1) { | ||
| text-align: center; | ||
| } | ||
| </style> |
This file contains hidden or 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 @@ | ||
| name = input("what is your name?\n") | ||
| print("Hello " + name) | ||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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: theory | ||
| custom_name: Your First Python Program | ||
| files: | ||
| - name: task.md | ||
| visible: false | ||
| - name: OurFirstPythonProgram.py | ||
| visible: true | ||
| - name: images/run.svg | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/run_dark.svg | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/hello_username.gif | ||
| visible: false | ||
| is_binary: true |
This file contains hidden or 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,25 @@ | ||
| ### Understanding the Code | ||
|
|
||
| ```python | ||
| name = input("what is your name?\n") # Gets input from you | ||
| print("Hello " + name) # Prints the greeting | ||
| ``` | ||
|
|
||
| - `input()` - Asks you to type something | ||
| - The Run tool window (at bottom) is where you type and see output | ||
| - `print()` - Shows messages on screen | ||
|
|
||
| **Try It!** | ||
|
|
||
| 1. Click the **Run** button () at the top right | ||
| 2. Type your name when asked | ||
| 3. Press Enter | ||
| 4. See your personalized greeting! | ||
|
|
||
| <img src="images/hello_username.gif" width="800"> | ||
|
|
||
| <style> | ||
| img { | ||
| display: inline !important; | ||
| } | ||
| </style> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 @@ | ||
| if __name__ == "__main__": | ||
| # Write your solution here | ||
| pass |
This file contains hidden or 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,13 @@ | ||
| type: theory | ||
| custom_name: Before You Continue | ||
| files: | ||
| - name: task.md | ||
| visible: false | ||
| - name: main.py | ||
| visible: true | ||
| - name: images/placeholder.png | ||
| visible: false | ||
| is_binary: true | ||
| - name: images/placeholder_dark.png | ||
| visible: false | ||
| is_binary: true |
This file contains hidden or 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 @@ | ||
| ### Entering Multiple Answers | ||
|
|
||
| In future tasks, you may see several input fields for your answers. The highlighted box in the image below shows where you need to enter them. | ||
|
|
||
| <img src="images/placeholder.png" class="center" width=800> | ||
|
|
||
| In such cases, the test checks all fields together. If you enter some correct answers but leave the others empty, the test will not pass. **Make sure to fill in all answer fields before running the test.** | ||
|
|
||
| ### Comments | ||
| In Python, comments start with the hash character (`#`) followed by a single space and extend to the end of the line. They are shown in gray in the editor and **do not affect how the program runs.** | ||
|
|
||
| ```python | ||
| attempt += 1 # Count the number of login attempts | ||
| ``` | ||
| You can read more about proper commenting in <a href="https://www.python.org/dev/peps/pep-0008/#comments">PEP 8 – Style Guide for Python Code</a>. |
This file contains hidden or 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,6 @@ | ||
| custom_name: Introduction | ||
| content: | ||
| - T01 | ||
| - T02 | ||
| - T03 | ||
| - T04 |
This file contains hidden or 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,14 @@ | ||
| # Operator Precedence Exercise | ||
| # Predict the output of each expression before you run the code | ||
| # Replace each placeholder value with your prediction (as a number) | ||
|
|
||
| # What will each of these print? | ||
| answer_1 = 45.0 | ||
|
|
||
| answer_2 = 45.0 | ||
|
|
||
| answer_3 = 45.0 | ||
|
|
||
| answer_4 = 25.0 | ||
|
|
||
| answer_5 = 25 |
This file contains hidden or 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,25 @@ | ||
| type: edu | ||
| custom_name: Operators And Precedence | ||
| files: | ||
| - name: task.md | ||
| visible: false | ||
| - name: ExerciseOperatorPrecedence.py | ||
| visible: true | ||
| placeholders: | ||
| - offset: 208 | ||
| length: 4 | ||
| placeholder_text: "# calculate (5 + 4) * 10 / 2" | ||
| - offset: 225 | ||
| length: 4 | ||
| placeholder_text: "# calculate ((5 + 4) * 10) / 2" | ||
| - offset: 242 | ||
| length: 4 | ||
| placeholder_text: "# calculate (5 + 4) * (10 / 2)" | ||
| - offset: 259 | ||
| length: 4 | ||
| placeholder_text: "# calculate 5 + (4 * 10) / 2" | ||
| - offset: 276 | ||
| length: 2 | ||
| placeholder_text: "# calculate 5 + 4 * 10 // 2" | ||
| - name: tests/test_task.py | ||
| visible: false |
This file contains hidden or 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,22 @@ | ||
| # Operator Precedence Exercise | ||
|
|
||
| ## Task | ||
| Calculate the results for the five expressions below and fill in the answers in `ExerciseOperatorPrecedence.py`. | ||
| Now calculate these 5 expressions and enter your answers. | ||
|
|
||
| ## Operator Precedence | ||
| Python evaluates operators in this order (highest to lowest): | ||
| 1. `**` (exponentiation) | ||
| 2. `*`, `/`, `//`, `%` (multiplication, division, floor division, modulo) | ||
| 3. `+`, `-` (addition, subtraction) | ||
| 4. Parentheses `()` override the default order | ||
|
|
||
| ## Your Task | ||
| Now calculate these 5 expressions and enter your answers. | ||
| ```python | ||
| answer_1 = ... # calculate (5 + 4) * 10 / 2 | ||
| answer_2 = ... # calculate ((5 + 4) * 10) / 2 | ||
| answer_3 = ... # calculate (5 + 4) * (10 / 2) | ||
| answer_4 = ... # calculate 5 + (4 * 10) / 2 | ||
| answer_5 = ... # calculate 5 + 4 * 10 // 2 | ||
| ``` | ||
This file contains hidden or 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,94 @@ | ||
| import importlib | ||
| import importlib.util | ||
| from io import StringIO | ||
| import os | ||
| import sys | ||
| import unittest | ||
| from unittest.mock import patch | ||
|
|
||
| TASK_NAME = 'operator_precedence' | ||
| TASK_FILE = os.path.join( | ||
| os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | ||
| 'ExerciseOperatorPrecedence.py' | ||
| ) | ||
|
|
||
|
|
||
| def try_import(): | ||
| return importlib.import_module(TASK_NAME) | ||
|
|
||
|
|
||
| class TestCase(unittest.TestCase): | ||
| task_name = TASK_NAME | ||
|
|
||
| def setUp(self): | ||
| try: | ||
| with patch('sys.stdout', new=StringIO()) as self.actualOutput: | ||
| if self.task_name in sys.modules: | ||
| del sys.modules[self.task_name] | ||
| spec = importlib.util.spec_from_file_location(TASK_NAME, TASK_FILE) | ||
| module = importlib.util.module_from_spec(spec) | ||
| spec.loader.exec_module(module) | ||
| sys.modules[TASK_NAME] = module | ||
| except NameError: | ||
| pass | ||
| except SyntaxError as se: | ||
| self.fail("Syntax error while loading the solution – {0}. " | ||
| "Please fill in all answers with valid numbers (empty placeholders are invalid)." | ||
| .format(str(se))) | ||
| except Exception as e: | ||
| self.fail("There was a problem while loading the solution – {0}. Check the solution for " | ||
| "IDE-highlighted errors and warnings.".format(str(e))) | ||
|
|
||
| def test_answer_1(self): | ||
| expected_value = 45.0 | ||
|
|
||
| try: | ||
| actual_value = try_import().answer_1 | ||
| except AttributeError: | ||
| self.fail(msg="The variable answer_1 seems to be undefined. Do not remove it from the task code.") | ||
|
|
||
| self.assertEqual(expected_value, actual_value, msg="The answer_1 value seems to be a bit off.") | ||
|
|
||
| def test_answer_2(self): | ||
| expected_value = 45.0 | ||
|
|
||
| try: | ||
| actual_value = try_import().answer_2 | ||
| except AttributeError: | ||
| self.fail(msg="The variable answer_2 seems to be undefined. Do not remove it from the task code.") | ||
|
|
||
| self.assertEqual(expected_value, actual_value, msg="The answer_2 value seems to be a bit off.") | ||
|
|
||
| def test_answer_3(self): | ||
| expected_value = 45.0 | ||
|
|
||
| try: | ||
| actual_value = try_import().answer_3 | ||
| except AttributeError: | ||
| self.fail(msg="The variable answer_3 seems to be undefined. Do not remove it from the task code.") | ||
|
|
||
| self.assertEqual(expected_value, actual_value, msg="The answer_3 value seems to be a bit off.") | ||
|
|
||
| def test_answer_4(self): | ||
| expected_value = 25.0 | ||
|
|
||
| try: | ||
| actual_value = try_import().answer_4 | ||
| except AttributeError: | ||
| self.fail(msg="The variable answer_4 seems to be undefined. Do not remove it from the task code.") | ||
|
|
||
| self.assertEqual(expected_value, actual_value, msg="The answer_4 value seems to be a bit off.") | ||
|
|
||
| def test_answer_5(self): | ||
| expected_value = 25 | ||
|
|
||
| try: | ||
| actual_value = try_import().answer_5 | ||
| except AttributeError: | ||
| self.fail(msg="The variable answer_5 seems to be undefined. Do not remove it from the task code.") | ||
|
|
||
| self.assertEqual(expected_value, actual_value, msg="The answer_5 value seems to be a bit off.") | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.