BackReturn Home

Socratica: Python

The YouTube channel Socratica has released a set of high-quality, bite-sized videos for learning the Python programming language. Each video is clear and to the point, with a dash of humour every now and then. This is a set of personal notes on that video series.

Contents

1 - Hello World in Python
2 - Python Strings
3 - Numbers in Python 2
4 - Numbers in Python 3
5 - Arithmetic in Python 2
6 - Arithmetic in Python 3
7 - Interactive Help
8 - Python Booleans
9 - Datetime Module (Dates and Times)
10 - If, Then, Else in Python
11 - Python Functions
12 - Sets in Python
13 - Python Lists
14 - Python Dictionaries
15 - Python Tuples
16 - Logging in Python
17 - Recursion, the Fibonacci Sequence, and Memoization
18 - Python Random Number Generator: the Random Module
19 - CSV Files in Python
20 - A Random Walk & Monte Carlo Simulation
21 - List Comprehension
22 - Python Classes and Objects
23 - Python and Prime Numbers
24 - PyDoc: A Celebration of Documentation
25 - XML and ElementTree
26 - JSON in Python
27 - Lambda Expressions and Anonymous Functions
28 - Map, Filter, and Reduce Functions
29 - Sorting in Python
30 - Text Files in Python
31 - Unit Tests in Python
32 - Exceptions in Python
33 - Urllib: GET Requests
34 - Special Methods
35 - Iterators, Iterables, and Itertools in Python
36 - Generators in Python
37 - Regular Expressions in Python
38 - SQLite in Python
39 - Decorators in Python


1 - Hello World in Python

[Video Link]

This lesson teaches how to:

• Check if Python is installed on your computer

For example: In Windows, open up a Command Prompt by going to Apps and typing in cmd. The Command Prompt icon should pop up. Click on it. In the window that appears, type python and hit Enter. If some text that says "Python" with some numbers after it comes up, then it is already installed. If not, then you may have to download it.

[Personal Warning: Sometimes getting Python to work on Windows can be a pain! You might want to try WinPython first instead.]

• How to use the print() command within the Python console

Generally, whatever is inside of the parentheses is displayed.

• How to exit the Python console with the quit() command

Just type it in and hit Enter. The Python console should close after that.

• How to make a file that opens in Python

Type out some code, such as a print() statment, in a plain text document, and then save it with the extension .py

[Personal Note: If you are wondering what text editor she is using in the video, it is Vim. Since there is a learning curve to Vim, you may or may not want use it if you are also trying to learn Python at the same time.]


2 - Python Strings

[Video Link]

This lesson teaches how to:

• How to store a string inside a variable

Similar to how the term is used within mathematics, a variable is a way to represent a whole range of different things. For example, here is a bit of code...

message = "Meet me tonight."

In this case, the variable is message, and everything after the equals sign is what it represents. A string is simply a list of items, be they letters, numbers, or some other symbols. Everything within the quotation marks is considered a string. Therefore, we used the equals sign to make a variable named message that represents a string containing the sentence Meet me tonight.

To view the string within the Python console, print the variable:

print(message)

We should get...

Meet me tonight.

We can also use apostrophes to specify the contents of a string:

message2 = 'The clock strikes at midnight.'

If we want a string that has an apostrophe within it, then we must use quotation marks:

message3 = "I'm looking for someone to share in an adventure."

If we want a string that has quotation marks within it, then we must use apostrophes:

message4 = 'The phrase "Beam me up, Scotty" was never said on Star Trek.'

If we want a string that has a combination of apostrophes and quotation marks, then we must contain it within three apostrophes or three quotation marks:

movie_quote = """One of my favorite lines from The Godfather is: "I'm going to make him an offer he can't refuse." Do you know who said this?"""

If our string is long, then it may take up more than one line. This will be represented by three dots in front of each new line. It might look something like this:

movie_quote = """One of my favorite lines from The Godfather is:
..."I'm going to make him an offer he can't refuse."
...Do you know who said this?"""


3 - Numbers in Python 2

[Video Link]


4 - Numbers in Python 3

[Video Link]


5 - Arithmetic in Python 2

[Video Link]


6 - Arithmetic in Python 3

[Video Link]


7 - Interactive Help

[Video Link]


8 - Python Booleans

[Video Link]


9 - Datetime Module (Dates and Times)

[Video Link]


10 - If, Then, Else in Python

[Video Link]


11 - Python Functions

[Video Link]


12 - Sets in Python

[Video Link]


13 - Python Lists

[Video Link]


14 - Python Dictionaries

[Video Link]


15 - Python Tuples

[Video Link]


16 - Logging in Python

[Video Link]


17 - Recursion, the Fibonacci Sequence, and Memoization

[Video Link]


18 - Python Random Number Generator: the Random Module

[Video Link]


19 - CSV Files in Python

[Video Link]


20 - A Random Walk & Monte Carlo Simulation

[Video Link]


21 - List Comprehension

[Video Link]


22 - Python Classes and Objects

[Video Link]


23 - Python and Prime Numbers

[Video Link]


24 - PyDoc: A Celebration of Documentation

[Video Link]


25 - XML and ElementTree

[Video Link]


26 - JSON in Python

[Video Link]


27 - Lambda Expressions and Anonymous Functions

[Video Link]


28 - Map, Filter, and Reduce Functions

[Video Link]


29 - Sorting in Python

[Video Link]


30 - Text Files in Python

[Video Link]


31 - Unit Tests in Python

[Video Link]


32 - Exceptions in Python

[Video Link]


33 - Urllib: GET Requests

[Video Link]


34 - Special Methods

[Video Link]


35 - Iterators, Iterables, and Itertools in Python

[Video Link]


36 - Generators in Python

[Video Link]


37 - Regular Expressions in Python

[Video Link]


38 - SQLite in Python

[Video Link]


39 - Decorators in Python

[Video Link]