## DEV Community

Vicki Langer

Posted on • Updated on

# Charming the Python: the basic basics

If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.

## Background

I have experience with Python, but saw this 30 day challenge and decided it could only help.

So, I went to the challenge content, added the Telegram group, and started to read day 1.

Note: This challenge was built to be beginner friendly and help people learn Python.

## Day 1 Topics

• installing python
• a simple script in IDLE
• math operators
• commenting
• installing VS Code
• starting with VS Code
• Data Types
• Exercises

### Math Operators

#### Addition `+`

``````a =  3
b =  4
print(a + b)  # 3 + 4 = 7
``````

#### Subtraction `-`

``````a =  3
b =  4
print(a - b)  # 3 - 4 = -1
``````

#### Muliplication `*`

``````a =  3
b =  4
print(a * b)  # 3 * 4 = 12
``````

#### Division `/`

``````a =  3
b =  4
print(a / b)  # 3 / 4 = .75
``````

#### Exponent `**`

``````a =  3
b =  4
print(a ** b)  # 3 ** 4 = 81
``````

The `**` is taking care of the exponent. If broken down it would look like `3 * 3 * 3 * 3`

#### Modulo `%`

``````a =  10
b =  3
print(a % b)  # modulo 10 % 3 = 1
``````

Use this operator if you only want the remainder or whats left over after the division. In this example, we've done `10 / 3` which give us 3 groups of 3 and a remainder of 1.

This could be used dividing time. You can use the remainder for the next smaller unit of time.

#### Floor Division `//`

``````a =  10
b =  3
print(a // b)  # floor division 10 // 3 = 3
``````

This is important to use when you can only have whole things. For example you can't have .5 of a person or .2 of a plane. So, you would round down so you're only using whole people and whole planes.

### Data Types

Type What Example
Integer whole numbers `1`
Float decimals `1.1`
Boolean True or False `True`
String characters in quotes `"4 bunch of ch4r4ct3r5!"`
List in order; may have different data types `['Dog', 9, False, 3.142]`
Dictionary key:value pairs `{"name":"Wiley", "breed":"unknown", age:2, "is_nuetered":True}`
Tuple cannot be changed `('Vicki', 1992, 'E5')`
Set may only have unique elements and may store different data types My name is Vicki, but a set would be `{'v', 'i', 'c', 'k'}`

Series based on