Skip to content

Update 02.Data-types-convertion-basic-operations.md #58

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
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
30 changes: 15 additions & 15 deletions 02.Data-types-convertion-basic-operations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lesson 2: Data Types

> In the world of programming, data types are the building blocks that shape the digital landscape."
> In the world of programming, data types are the building blocks that shape the digital landscape.


## Content
Expand Down Expand Up @@ -30,7 +30,7 @@ my_age = 22

print("There are", number_of_apples, "apples in the basket")
print(type(number_of_apples))
print("My age is:" my_age)
print("My age is:", my_age)
print(type(my_age))
```

Expand All @@ -42,7 +42,7 @@ My age is: 22
<class 'int'>
```

As `python` is a dynamical language (it means that the programmer doesn't declare types _explicitly_) this can cause some issues in the future with advanced data types. So if you are not sure what type is stored in the variable don't hesitate to call `type()`.
As `Python` is a dynamical language (it means that the programmer doesn't declare types _explicitly_), this can cause some issues in the future with advanced data types. So if you are not sure what type is stored in the variable, don't hesitate to call `type()`.

### 1.1 float

Expand All @@ -56,7 +56,7 @@ Sometimes, you'll see really big or small floats written with an "e" which is ju
# Float
apple_price = 0.99

print("Apple price:", apple_price, "pounds")
print("Apple price:", apple_price, "dollars")
print("Type of apple_price variable:", type(apple_price))
```

Expand All @@ -73,7 +73,7 @@ In `Python`, you can perform _all_ the basic mathematical operations you're fami
This includes `addition`, `subtraction`, `multiplication`, `division`, and even more complex operations like `exponentiation`.


Here are the the table where each operator described within `Python` syntax"
Here is a table that describes each operator.


| Operator | Description |
Expand Down Expand Up @@ -122,7 +122,7 @@ Exponentiation of 15 to the power of 4 = 50625
Modulo of 15 by 4 = 3
```

Here is a practical task which we remeber from school, where we need to calculate the `circumference` of the circle
Here is a practical task, which you may remember from school, where we need to calculate the `area` and `circumference` of a circle.

#### Example

Expand Down Expand Up @@ -157,7 +157,7 @@ Circumference of the circle: 31.4159

A string in `Python` is a _series of characters_. It is used to represent text.

As you know already, strings in `Python` are enclosed either in single quotes `(')` or double quotes `(")`, and they can include _letters_, _numbers_, and _various symbols_. Also when we ask a user for input, we store the `str` type into the variable.
As you know already, strings in `Python` are enclosed either in single quotes `(')` or double quotes `(")`, and they can include _letters_, _numbers_, and _various symbols_. Also when we ask a user for input, we store the input provided by the user into a `str` type variable.

#### Example
```python
Expand All @@ -174,10 +174,10 @@ print("Name of the student is", student_name)
#### Output

```python
Hello, Python learners!
The course you are taking is called: The best Python Course in the United Kingdom, or even in the world!

Input your name:
>> Adam
Hello, Python learners!
The course you are taking is called: The best Python Course in the United Kingdom, or even in the whole world!
Name of the student is Adam
```

Expand Down Expand Up @@ -212,7 +212,7 @@ It's especially important when the data type of a value <span style="color:red">

### 4.1 Implicit Conversion

In this example, `Python` automatically converts data types after ariphmetical operation.
In this example, `Python` automatically converts data types after an arithmetical operation.

#### Example

Expand All @@ -238,9 +238,9 @@ Type of total: <class 'float'>

Explicit conversion requires the programmer to convert data types manually. Python provides functions like `int()`, `float()`, `str()`, etc.. <span style="color:orange">for explicit conversions. <span>

There are several examples provided below which explain the need of such converstaions.
There are several examples provided below that explain the need of such conversations.

If we try to make math operations between strings, it will result in an error:
If we try to apply math operations to strings, it will result in an error:

#### Incorrect Usage

Expand All @@ -265,11 +265,11 @@ Traceback (most recent call last):
TypeError: unsupported operand type(s) for -: 'str' and 'str'
```

**Note:** In such cases we would want to convert the `types` of variables
**Note:** In such cases we would want to convert the `types` of variables.

#### Correct Usage

This is a recommended approach
This is a recommended approach.

```python
# These variables are ``strings`` representing ``numbers``
Expand Down