Python 101 A Crash Course
Python 101 A Crash Course
PYTHON 101
A CRASH COURSE
LEARNPYTHONWITHRUNE.ORG
What Makes This Python
Crash Course Different?
Did you know that most people don’t understand what
programming is?
In the first lesson you will be introduced to them, for now, you
need to install Anaconda.
On the next page, you will download the Notebooks with all
the lessons and projects you will do in this course.
WHY HOW WHAT
PYTHON LEARNING LESSONS
Notebooks
IMPORTANT You need to download all the Notebooks and
course material to follow along.
The above link will download a ZIP file with all the
Notebooks and files.
https://github.com/LearnPythonWithRune/LearnPython
LESSON
00
WHY
PYTHON
HOW
LEARNING
WHAT
LESSONS
Learn Python
In this first lesson, we will learn to take input from the user
and print it. Also, how to apply string methods that convert the
string to upper case or similar.
LESSON
WHY
PYTHON
01HOW
LEARNING
WHAT
LESSONS
1 type(b)
LESSON
WHY
02
PYTHON
HOW
LEARNING
WHAT
LESSONS
03
WHY
PYTHON
HOW
LEARNING
WHAT
LESSONS
1 if a == b:
2 print("a equals b")
LESSON
04
WHY
PYTHON
HOW
LEARNING
WHAT
LESSONS
The goal of this lesson is to teach you how to use the Python
random number generator.
In the project, you will create a Math game and the classical
Rock-Scissor-Paper game.
1 import random
2 a = random.randint(1, 6)
3 b = random.uniform(0, 1)
4 c = random.gauss(0, 1)
LESSON
WHY
05
PYTHON
HOW
LEARNING
WHAT
LESSONS
Python lists are versatile and easy to use. The Python list can
be used for containing any Python types or objects.
1 import random
2 random.choice(new_list)
3 random.shuffle(new_list)
LESSON
06
WHY
PYTHON
HOW
LEARNING
WHAT
LESSONS
The goal of this section is to teach you how to use Python for
and while loops. The while loop is especially powerful when
there is user input in form of a string like we will use in the
project.
WHY
07
PYTHON
HOW
LEARNING
WHAT
LESSONS
1 def print_name(name):
2 print(f"Hello {name}")
3
4 print_name("Rune")
LESSON
08
WHY
PYTHON
HOW
LEARNING
WHAT
LESSONS
1 my_dict = {
2 'Key 1': 'Value 1',
3 'Key 2': 'Value 2'
4 }
LESSON
09
WHY
PYTHON
HOW
LEARNING
WHAT
LESSONS
Learn how to read CSV files with DictReader in Python. This will
read the CSV content into a Python list of dictionaries
representing one row each with key-value pairs.
In this lesson, you will learn what a CSV file is, and how do you
read a CSV file in a convenient way in Python. Also how to
iterate over the CSV content with a for-loop in Python.
This can all be done simply by using the CSV library with the
DictReader.
In the project, you will read a huge CSV file and make some
nice data processing utilizing what you have just learned.
1 import csv
2 with open("files/NameRecords.csv", "r") as f:
3 csv_reader = csv.DictReader(f)
4 name_records = list(csv_reader)
LESSON
WHY
PYTHON
10
HOW
LEARNING
WHAT
LESSONS
1 def count(n):
2 if n <= 0:
3 return n
4 return n + count(n - 1)
LESSON
WHY
PYTHON
11
HOW
LEARNING
WHAT
LESSONS
List Comprehension
In the project, we will re-do some of our previous code with list
comprehension. Specifically, we will make the Caesar Cipher
encryption and decryption with List Comprehension. Also, we
will make Frequency count with Dict Comprehension.
WHY
PYTHON
12
HOW
LEARNING
WHAT
LESSONS
Object-Oriented Programming
1 class Card:
2 def __init__(self, suit, rank):
3 self.suit = suit
4 self.rank = rank
LESSON
WHY
PYTHON
13
HOW
LEARNING
WHAT
LESSONS
Matplotlib Visualization
When working with data you need to be able to visualize it.
This is easy with the Python library Matplotlib.
WHY
PYTHON
14
HOW
LEARNING
WHAT
LESSONS
In the project, we will use real-world data and see how well the
Linear Regression model can predict a connection between
Horsepower and Torque.
WHY
PYTHON
15
HOW
LEARNING
WHAT
LESSONS
In the project, we will read a sales dataset and make some nice
Excel sheets with charts representing the sales reps.
1 d = {
2 'Cars': ['Fiat', 'Porsche', 'Ferrari', 'Ferrari'],
3 'Speed': [120, 215, 305, 195]
4 }
1 import pandas as pd
2 df = pd.DataFrame(d)
LESSON
WHY
PYTHON
16
HOW
LEARNING
WHAT
LESSONS
In this last lesson, you will make your Cap Stone project.
Creating your own Machine Learning model from scratch. First,
we will learn what the Reinforcement model is, how it works,
and a description of the algorithm.
But...
It is the first step
Don't expect
to write big programs
not to need help