Skip to content

Commit

Permalink
Merge pull request #64 from aravinds-arv/aravind
Browse files Browse the repository at this point in the history
Fixing some errors in Lessons 0, 1 & 2
  • Loading branch information
Bharath314 authored Oct 22, 2023
2 parents 1b19cef + 669c5bd commit f3ac64d
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 133 deletions.
160 changes: 160 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
6 changes: 3 additions & 3 deletions docs/chapter-0/lesson-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## What is Python?
To answer this question, we need to first ask _What is a programming language?_ A **programming language** is essentially a language in which you can tell your computer what to do. You will understand what that means as start programming. Every programming language has its own strengths and purposes. **Python** is a general-purpose programming language that can be used for a wide variety of purposes including but not limited to data science, automation, machine learning and software and web development. A typical python program to find the sum of the first 100 numbers looks like this:

```python
```python linenums="1"
sum = 0
for number in range(1, 101):
sum += number
Expand Down Expand Up @@ -96,7 +96,7 @@ We will be using Python-3.8 or higher throughout these lessons. If some of you a

## Setting up Replit

Replit is an online environment where we can write code. It is an ideal place to learn programming and we will be using it extensively in this course. Head to http://www.replit.com/ and sign up using your Online Degree account. Replit provides an excellent [tutorial](https://docs.replit.com/tutorials/01-introduction-to-the-repl-it-ide) to get you started.
Replit is an online environment where we can write code. It is an ideal place to learn programming and we will be using it extensively in this course. Head to [replit.com](http://www.replit.com/) and sign up using your Online Degree account. Replit provides an excellent [tutorial](https://docs.replit.com/getting-started/intro-replit) to get you started.

## Installing Python on your System

Expand Down Expand Up @@ -125,4 +125,4 @@ Python is 30 years old. Programmers who boarded the Python-bus 30 years back lov
2. Have a look at this interesting [interview](https://blog.dropbox.com/topics/work-culture/-the-mind-at-work--guido-van-rossum-on-how-python-makes-thinking) of Guido Van Rossum. This is a blog maintained by Dropbox. Another trivia: Guido worked at Dropbox for six and a half years.
3. Try to watch documentaries and interviews on the web where Guido talks about how Python came into existence. It is always good to know about some non-technical aspects of the language, such as its history and something about the people who were behind its development. It gives a humanistic flavor to technology. We often forget that a lot of software is written by humans, for humans.
4. In the next few weeks to come, [StackOverflow](https://stackoverflow.com/) might become the most visited website by most of you. Some of you might be familiar with it, but for the others, StackOverflow is a question-answer forum for programming related questions. It is extremely popular not just among beginners but even experienced developers. Do check it out, but use it wisely. Refrain from using it to get answers to assignment questions; you won't learn anything that way.
5. You can also look into the official documentation on the python [website]((https://docs.python.org/3/)).
5. You can also look into the official documentation on the python [website](https://docs.python.org/3/).
2 changes: 1 addition & 1 deletion docs/chapter-1/lesson-1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Hello World!

The sentence enclosed by the parentheses of the `#!py print()` function is called a **string**. A **string** is a sequence of characters enclosed in quotes. Strings can either be in single quotes or double quotes. However, a single quote can't be matched against a double quote to enclose a string. We have used single quotes in line 1 and double quotes in line 3. Both lines give identical outputs. The ability to use both single quotes and double quotes comes in handy in situations like this:

!!! question "Problem"
!!! question " "
Print a string that has an apostrophe in it:

```pycon
Expand Down
18 changes: 9 additions & 9 deletions docs/chapter-1/lesson-1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ True

### Operator Chaining

Python supports chaining relational operators. This enables you to evaluate chains of comparison without having to use logical operators.
```python
>>> 10 < 11 <= 12
True
# is the same as
>>> 10 < 11 and 11 <= 12
True
```
Python supports chaining relational operators. This enables you to evaluate chains of comparison without having to use logical operators.
```python
>>> 10 < 11 <= 12
True
# is the same as
>>> 10 < 11 and 11 <= 12
True
```

## Expressions

Expand Down Expand Up @@ -281,4 +281,4 @@ We can take the help of a concept called **truth table** to analyze the outcomes
| True | False | True |
| False | True | True |
| False | False | False |
</div>
</div>
2 changes: 1 addition & 1 deletion docs/chapter-1/lesson-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The interpreter throws a `TypeError`. The message accompanying the error is more

The next exception that we will frequently encounter is `NameError`.

```python
```python linenums="1"
print('There is no problem with this line')
print(x ** 2)
```
Expand Down
32 changes: 16 additions & 16 deletions docs/chapter-1/lesson-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ third line

The following code will throw a `SyntaxError`:

```python
```python linenums="1"
x = 'first line
second line
third line'
Expand All @@ -35,7 +35,7 @@ print(x)

This is where `'''` comes in:

```python
```python linenums="1"
x = '''first line
second line
third line'''
Expand All @@ -56,21 +56,21 @@ The `\n` character that you see above is called a newline character. Head to the

The length of a string is the number of characters in it. Python provides a built-in function called `len` to find the length of a string:

```python
```python linenums="1"
x = 'good'
print(len(x))
```

The code given above will give 4 as the output. If you are familiar with other programming languages, such as C, you might be aware of a character data type. Python doesn't have a separate data type for characters. A character in Python is represented by a string of length 1. In the following examples, `x` and `y` are strings of length 1.

```python
```python linenums="1"
x = 'a'
y = 'b'
```

We can also define empty strings:

```python
```python linenums="1"
x = ''
print(len(x))
```
Expand All @@ -85,7 +85,7 @@ As expected, the length of the empty string is 0.

We can concatenate two strings using the `+` operator. Concatenation is just a fancy term for joining two strings together:

```python
```python linenums="1"
string1 = 'first'
string2 = ','
string3 = 'second'
Expand All @@ -105,7 +105,7 @@ first,second

We can make multiple copies of a string and string them all together using the `*` operator:

```python
```python linenums="1"
s = 'good'
five_s = s * 5
print(five_s)
Expand All @@ -119,7 +119,7 @@ goodgoodgoodgoodgood

The `*` operator has made the string look too good! This is a fine demonstration of that ancient adage: "multiplication is repeated addition":

```python
```python linenums="1"
s = 'good'
s * 5 == s + s + s + s + s # This expression evaluates to True
```
Expand All @@ -130,7 +130,7 @@ s * 5 == s + s + s + s + s # This expression evaluates to True

We can compare two strings. To begin with, we have the `==` operator:

```python
```python linenums="1"
x = 'python'
print(x == 'python', x == 'nohtyp')
```
Expand All @@ -143,7 +143,7 @@ True False

Two strings are equal if and only if both of them represent exactly the same sequence of characters. Now, consider the following lines of code:

```python
```python linenums="1"
print('good' > 'bad')
print('nine' < 'one' )
print('a' < 'ab' < 'abc' < 'b')
Expand All @@ -169,14 +169,14 @@ Python’s string type uses the Unicode standard for representing characters, wh

Python provides a built-in function called `ord` that returns the code point of any given character. For example:

```python
```python linenums="1"
print(ord('a'), ord('b'))
print(ord('a'), ord('A'))
```

The output is:

```python
```
97 98
97 65
```
Expand All @@ -189,7 +189,7 @@ Now, we clearly see why `'a' < 'b'` returns `True`. This is because the code poi

In Python, the backslash - `\` - is called the escape character. One of its uses is to represent certain white-space characters such as tabs and newlines. We will look at them one by one using the following examples:

```python
```python linenums="1"
print('This is the first sentence.\nThis is the second sentence.')
```

Expand All @@ -202,7 +202,7 @@ This is the second sentence.

`\n` is a newline character. Its effect is to introduce a new line. Note that even though there are two separate characters: `\` and `n`, `\n` is still regarded as a single character. To verify this, execute the following code. You should get 1 as the output.

```python
```python linenums="1"
x = '\n'
print(len(x))
```
Expand Down Expand Up @@ -239,7 +239,7 @@ Now remove the backslash from the above string and try to print it. You will get

A string is a substring of another string if the first string is contained in the second. For example, `'good'` is a substring of `'very good'`, whereas `'very good'` is not a substring of `'verygood'`. Python provides a keyword - `in` - which can be used to check if a given string is a substring of another string. For example:

```python
```python linenums="1"
a = 'good'
b = 'very good'
present = a in b
Expand All @@ -257,7 +257,7 @@ False

`in` is a powerful keyword which has several other uses. It can also be used along with `not` in the following manner:

```python
```python linenums="1"
a = 'abc'
b = 'ab'
print(a not in b)
Expand Down
Loading

0 comments on commit f3ac64d

Please sign in to comment.