Skip to main content

Charming Python: Day 1 of 30

30 Days of Python (3 Part Series)
1) Charming Python: Day 1 of 302) Charming Python: Day 2 of 303) Charming Python: Day 3 of 30

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.
Link: Day 1 content
Note: This challenge was built to be beginner friendly and help people learn Python.

Day 1 Topics

  • installing python
  • a simple script in IDLE
  • addressing a syntax error
  • 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

TypeWhatExample
Integerwhole numbers1
Floatdecimals1.1
BooleanTrue or FalseTrue
Stringcharacters in quotes"4 bunch of ch4r4ct3r5!"
Listin order; may have different data types['Dog', 9, False, 3.142]
Dictionarykey:value pairs{"name":"Wiley", "breed":"unknown", age:2, "is_nuetered":True}
Tuplecannot be changed('Vicki', 1992, 'E5')
Setmay only have unique elements and may store different data typesMy name is Vicki, but a set would be {'v', 'i', 'c', 'k'}
30 Days of Python (3 Part Series)
1) Charming Python: Day 1 of 302) Charming Python: Day 2 of 303) Charming Python: Day 3 of 30
   twitter logo DISCUSS 
Sore eyes?
dev.to now has dark mode.
Go to the "misc" section of your settings and select night theme ❤️

Comments

Popular posts from this blog

Easy Text-to-Speech with Python

Flutter for Single-Page Scrollable Websites with Navigator 2.0

Better File Storage in Oracle Cloud