Skip to content
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

Update 03.Conditionals-and-strings.md #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions 03.Conditionals-and-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Relational operators in `Python` are used to compare the values on either side o
| `>=` | Greater than or equal to | `5 >= 5`| `True` |
| `<=` | Less than or equal to | `5 <= 3`| `False` |

The order of calculation is the same as in math
The order of calculation is the same as in math.

## 2. Logical Operators (`if/elif/else`)

Expand All @@ -40,7 +40,7 @@ However, in Python, indentation is an integral part of the code structure. Incor

#### Example

The correct indentation should be 4 spaces according to the PEP-8 standart.
The correct indentation should be 4 spaces according to the PEP-8 standard.

```python
if condition:
Expand Down Expand Up @@ -68,7 +68,7 @@ if condition:

Follow the rules of indentations during this course, and you will get the general idea of constructions which require them.

Don't worry if this seems to be hard for now, with more practice indendtaion will never be a problem even in complex applications.
Don't worry if this seems to be hard for now, with more practice indentation will never be a problem even in complex applications.

### 2.1. `if` Statement

Expand All @@ -91,7 +91,7 @@ if y < 5: # is not ``True`` --> the code within ``if`` block WON'T BE
x is greater than 5
```

Let's write a mini program to verify, that you actually learning Python and allowed to attend this course.
Let's write a mini program to verify that you are actually learning Python and allowed to attend this course.

#### Example

Expand Down Expand Up @@ -136,7 +136,7 @@ Which programming language are we learning? # Asking for user's input

# Case 1
>> Python
Correct
Correct!

# Case 2
>> Java
Expand Down Expand Up @@ -349,7 +349,7 @@ Example: If the intervals are -3 to 7 (inclusive), and the user enters 5, the ou

#### Assignment 2: Interval Membership p.2

**Objective**: Create a program that accepts an integer x and determines whether `x` belongs to any of the given intervals.
**Objective**: Create a program that accepts an integer `x` and determines whether `x` belongs to any of the given intervals.

```
Input:
Expand Down Expand Up @@ -389,7 +389,7 @@ Example: If the user enters 3, 4, and 5, the program should output 'YES'.

## 4. Strings

Previosuly we saw `strings` and know how to delcare them, but how to work with them?
Previously we saw `strings` and know how to declare them, but how to work with them?

### 4.1 Basic `str` operations

Expand All @@ -398,6 +398,9 @@ Strings can be concatenated (glued) with the `+` operator, and repeated with `*`
#### Example

```python
greeting = "Hello"
name = "World"

# Concatenation
full_greeting = greeting + ', ' + name + '!'

Expand Down Expand Up @@ -475,7 +478,7 @@ False

Often, you need to access a specific character in a string. In Python, this is done using square brackets `[]` with the `index (number) `of the desired character.

***NOTE***: The count in `Python` starts from `0` and the 1st element of any data structure we will learn will be `0` element!
***NOTE***: The count in `Python` starts from `0` and the 1st element of any data structure we will learn will be the `0` element!

Let's say we have the following string:

Expand All @@ -502,7 +505,7 @@ Negative `indices` start from `-1` for the <span style="color:red">last characte
| ---------- | ----------- | ----------- |
| `s[-1]` | n | 6th character of string |
| `s[-4]` | t | 3rd character of string |
| `s[-3]` | h | 6th character of string |
| `s[-3]` | h | 4th character of string |

#### Output

Expand Down Expand Up @@ -683,7 +686,7 @@ You walk into the forest and find a hidden treasure chest!

### Task 3: Travel Itinerary Planner

**Objective**: Plan your futre holiday, you might be tired already :)
**Objective**: Plan your future holiday, you might be tired already :)

```
Input: The user enters three cities they plan to visit.
Expand Down