-
Notifications
You must be signed in to change notification settings - Fork 36
Added lesson summary folder #11
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
davisweilun
wants to merge
1
commit into
ytbryan:main
Choose a base branch
from
davisweilun:topics
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
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,46 @@ | ||
| ###Introducing the REPL for Rapid Experimentation | ||
|
|
||
| Python is an interpreted language, and the code is evaluated line-by-line. | ||
| Each line can be evaluated by itself, and this allows us to have a REPL. | ||
|
|
||
|
|
||
| What is a REPL? | ||
|
|
||
| >REPL stands for: Read, Evaluate, Print, Loop | ||
|
|
||
| >Each line is read, evaluated, the return value is then printed to the screen, | ||
| and then the process repeats. | ||
|
|
||
| >Python ships with a REPL, and you can access it by running python3.6 from your terminal. | ||
|
|
||
| Eg.1: | ||
| $ python3.6 | ||
| Python 3.6.4 (default, Jan 5 2018, 20:24:27) | ||
| [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux | ||
| Type "help", "copyright", "credits" or "license" for more information. | ||
| >>> | ||
|
shankjs marked this conversation as resolved.
|
||
|
|
||
| Expln 1: | ||
| The >>> indicates that you can type on that line. Later on, you’ll also see a ... which | ||
| means that you are currently in a scoped area and will need to enter a blank line (no spaces) | ||
| before it evaluates the entire code block. | ||
|
|
||
| The simplest use of this would be to do some math: | ||
|
|
||
| Eg.2: | ||
| >>> 1 + 1 | ||
| 2 | ||
| >>> | ||
|
|
||
| Expln 2: | ||
| 2 is the return value of the expression, and it is then printed to the screen. If something | ||
| doesn’t have a return value, then nothing will be printed to the screen and you’ll see the | ||
| next prompt immediately. We’ll cover this later, but an example would be None: | ||
|
|
||
| Eg.3: | ||
| >>> None | ||
| >>> | ||
|
|
||
|
|
||
| Lastly, to exit the REPL, you can either type exit() (the parentheses are important), or you | ||
| can hit Ctrl+d on your keyboard. | ||
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,37 @@ | ||
| ###Lesson Description - Using Comments | ||
|
shankjs marked this conversation as resolved.
|
||
|
|
||
| When writing scripts, we often want to leave ourselves notes or explanations. | ||
| Python (along with most scripting languages) uses the # character to signify | ||
| that the line should be ignored and not executed. | ||
|
|
||
|
|
||
|
|
||
| Single Line Comment | ||
|
|
||
| We can comment out a whole line: | ||
|
|
||
| Eg. 1 # This is a full like comment | ||
|
shankjs marked this conversation as resolved.
|
||
|
|
||
| or we can comment at the end of a line: | ||
|
|
||
| Eg. 2 2 + 2 # This will add the numbers | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| What About Block Comments? | ||
|
|
||
| Python does not have the concept of block commenting that you may have encountered | ||
| in other languages. Many people mistake a triple-quoted string as being a comment, | ||
| but it is not, it’s a multi-line string. That being said, multi-line strings can | ||
| functionally work like comments, but they will still be allocated into memory. | ||
|
|
||
| Eg. 3 | ||
| """ | ||
| This is not a block comment, | ||
| but it will still work when you really need | ||
| for some lines of code to not execute. | ||
| """ | ||
|
shankjs marked this conversation as resolved.
|
||
|
|
||
|
|
||
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.