
Welcome to Python
Welcome to coding. Welcome to Python. And Welcome to The Python Coding Place. Hopefully you'll stick with coding and Python, and also with The Python Coding Place
The best course for you is the one that you connect with most, the one that delivers content in a tone and style that suits you. If my style is that style, then we'll get to know each other well over many hours
No potten plants and fancy bookcases in the background of my videos. The star of the show is the Python code we'll write together.
When I record these videos, I imagine sitting in a quiet, comfortable coffee shop where we're talking casually about Python coding.
Try out a few videos, and if you like them, just keep going…
What's Coding?
Yes, I know you know what coding is already. But bear with me, listen to how I see coding.
We communicate with other humans all the time. Knowing a common language with our audience is important, but there's more to human-to-human communication.
Coding is communication with a computer. We want to convey our ideas of what we want the computer to do to the computer.
And yes, we also need a language to translate our ideas into something the computer can read. That's Python in this case.
Programming is a mindset—learning to think in a way that's compatible with computers.
Installing the Software
If you already have a setup to code in Python that you're happy with, keep it. Don't let anyone tell you "You should use this editor and this configuration to code". Find what you're comfortable with.
But if you're new to coding, then you can follow these steps to install Python and an editor. I'll use PyCharm in my videos, so you can use the same software if you don't already have a preferred editor.
Install Python
First, you'll need to install Python, the language.
Go to the Python home page (link in resources)
Hover on the Downloads tab and click the button to install Python. This link will download the latest version, which is the one you want to use.
Once the download is complete, run the installer. You can choose all the default options when you're asked any question during installation.
You don't need to run anything. As long as Python is installed on your computer, you can move on to the next download and installation.
Install PyCharm Community Edition
The language is not enough. You need an editor to write code and manage your projects. Although Python comes with a basic editor, I'll recommend you use one of the standard IDEs (Integrated Development Environment)—that's a fancy word for an all-in-one software for your coding.
Go to the Jetbrains homepage and look for PyCharm's download page (link in resources)
There are two versions of PyCharm on this page. Don't choose the more prominent one, the Professional Edition, since this required a paid license. Instead, scroll down to get PyCharm Community Edition, which is free and more than enough for your current.
Once the download is complete, run the installer. You can again choose all the default options when you're asked any question during installation.
Once you've installed PyCharm, launch it, again choosing the default options during any set up steps presented to you.
Create a New Project. A project is a folder with all the files that belong together. I recommend you create a single project for all the lessons we'll work on in this course. Don't create a project for each lesson!
You'll be asked to choose your Interpreter. PyCharm wants to know how you want Python set up. Go with the defaults again. This will create something called a Virtual Environment (don't worry about what this is for now) using the version of Python you have just installed. In future, you may have more than one version of Python installed on your computer and you can use different ones for different projects.
And you're in! Now, From the File menu, choose New... (not the menu item that says New Project, since you're already created a project, but the one the simply says New...)
From the window that comes up, choose Python File (not the option that just says File)
If you don't see any options in the little window that pops up on your screen, make sure your project/folder is selected in the Project sidebar on the left (you may need to open the sidebar first) and then try again.
Name your file anything you want, and you're ready to code
Introducing the first project
Nothing much to say in these notes for this first video. Before we can start coding, we need to understand the game. But this is an easy game to understand…
Passing information between program and user
Remember you have two hats: the programmer's hat and the user's hat. When you have the programmer's hat on, you know what's in the computer program. But you should also put the user's hat on when running your code. The user doesn't know what's in the code.
The program often needs to show some information to the user. You can use the `print()` function for this. It's a one-way form of communication: from program to user.
You can also use `input()` which is a two-way form of communication. The program sends text to the user but the user can also type something and send it back into the program. The program then has access to whatever the user of the program wrote.
You create a string when you use quotation marks in your Python code. You can use single or double quotation marks. The text inside a string is something for the human to understand. The words in a string are not Python commands.
String is short for a a string of characters.
Storing information
A computer program deals with data. There's information that you need to use in different parts of the program.
You can assign data to a variable name using =
You can choose (almost) any name for your variable. This goes on the left of the equals sign.
Then you can put the information you want to store on the right of the equals. This could also be a function that gives some information back when it runs, such as `input()`.
You can think of this as a box which stores things. The variable name is the label you use to identify the box. We'll talk more about these boxes later in this course.
f-strings: We can format strings by adding information stored in the program within a string.
Concatenating strings
There are many ways of sticking strings together into one string. The simplest is to add them using a +, but this is only suitable for simple concatenations.
The modern way of dealing with these situations is to used formatted strings, or f-strings. You can put an f before the quotation marks to turn it into an f-string, and then add Python variable names or other statements in curly brackets {} withing the string.
There's also the `.format()` method you can use with strings. I used the term "method" there. Don't worry about what this is for now. It's a function that performs an action on a string in this case.
Making decisions: `if` statements
Often, you need the computer program to make a decision. This is not a decision you, the programmer, can make when writing the program. It's a decision that only the program can make while it's running.
You can use an `if` statement for this. The keyword `if` must be followed by something that Python understands as true or false. In Python, there are built-in constants `True` and `False`.
The block of code that follows the `if` statement will only run if the condition following `if` is true (I'll phrase this differently: it needs to be something that Python understands as true. We'll get back to this wordier version later)
The lines that "belong" to the `if` statement are the ones which have an indent—a space at the beginning of the line.
There's a difference between = and == in Python:
= is used to assign data to a variable name. It stores information
== asks the question "are the two things on either side of the == the same?". It wlil say `True` if they are and `False` if they're not.
We'll revisit the `if` statement at the end of this Chapter.
We have a bug • Introduction to data types
It doesn't work! The code never tells us we won even when we put the correct number.
`input()` gives us a string back, even if the user types in a number. So if you type the number 3 in your program, this will return "3", the character not the number.
So, if you compare "3" with 3, Python will say they're not the same. "3" == 3 gives back `False`.
Every bit of information in a program has a certain type. The data type of everything is important since it affects many properties and actions we can do.
"3" and "Stephen" are strings
3 and 42 are integers, whole numbers
5.5 and 2.53 are floats, numbers which are not whole numbers!
`while` loop
Often, you'll need to repeat a block of code several times. You need a loop for this. One type of loop in Python is the `while` loop.
In its simplest form, you can write `while True`, which repeats the block of code that comes after this statement forever.
We see the colon and indents again. We used colons and indents with `if` and now againn with `while`. We'll see the colon and indent pair often in Python.
Stopping the `while` loop
We introduce the Boolean data type. This is something that can only have two values: `True` or `False`.
It's useful in many instances when we need to store information that can only have one of two values.
We can use it as a "switch" to turn things on or off. We often use the term "flag" for this, but I like to think of it as a light switch you can turn on and off.
You can use a Boolean to turn the `while` loop off when a condition is met, such as the player guessing the answer.
Importing modules
When you open a new Python script, you only have access to a limited number of functions and keywords. But Python has a large number of tools you can use.
You can import modules using the `import` keyword.
I'll talk about an analogy later on in this course which I like to use. Here's a preview:
Imagine a large old-fashioned library with lots of books covering the walls
Each book has lots of Python words you can use. And each book has a theme
You can bring these books into your program using `import`. Then, you'll have access to whatever is in this book within your program.
One such module is the `random` module which has lots of tools to deal with randomness, such as creating random numbers.
Finishing touches
We were using the number 5, for the number of doors in the game, in several places in our code. We want to avoid this, so we create a `number_of_doors` variable, which contains 5, or any other number of doors.
We add some comments to annotate our code.
Happy goblin-hunting!
`if`, `elif` and `else`
You can have an `if` statement by itself. So the code in the `if` block will happen if `if` is followed by something that Python understands as true but it won't happen otherwise.
You can also add more conditions after `if` by using `elif` statements. This stands for "else if". So if the first `if` statement is false, the next condition is checked. And you can have as many `elif`s as you want following the first `if`.
You can also add an `else` clause at the end of all the `if` and `elif` clauses. The `else` doesn't need any condition. It catches all the situations that are not covered by `if` or `elif`.
You must have an `if` statement, but you don't always need to have `elif` or `else`.
Store. Repeat. Decide. Reuse.
A lot of what happens in a computer program falls under one of these crude categories:
Store: Storing information to use later in the program, such as by creating variable names and assigning data to these names.
Repeat: Repeating a block of code several times, such as by using loops.
Decide: Your program will need to make decisions on how to proceed. You can get the program to make decisions using `if` statements, for example.
Reuse: We'll come to this later in this course…
If you want to read more than just these short bullet points, you can look at The Python Coding Book. I'm broadly following the material in that book. Most of what we've discussed in this Chapter can be found in Chapter 1.
Monty and The White Room Analogy
We introduce an analogy that's central to this course, which explains how a Python program works.
Imagine an empty room. There are only a few shelves on one of the walls.
The only object in the room at the start of a program is a red booklet called "built-in" on one of the shelves.
Monty reads each word you write in your code. When he reads a name like `print`, he looks around the room to find a reference to this name. He only finds it in the red booklet.
But when Monty reads a name he doesn't find anywhere, he'll complain with a `NameError`
Monty and The White Room Analogy
When you create a variable using the equals sign, Monty fetches an empty cardboard box, puts whatever is on the right-hand side of the equals in the box, and labels the box with the name on the left-hand side of the equals. He puts the box on a shelf, label facing outwards.
When Monty reads the same name later in the program, he spots the label on the box, brings the box down from the shelf, and fetches its contents.
When Monty reads the line `import random`, he leaves the room, walks across Python City to the central library where he finds a book named `random`. He borrows the book and takes it back to the room where he puts is on a shelf with the spine facing outwards.
When Monty reads the name of the book (module) later in the program, he'll fetch the book from the shelf and look inside it.
DRY: Don't Repeat Yourself and The `for` Loop
A key principle in programming is DRY, which stands for Don't Repeat Yourself. As a programmer, you want to avoid repetition. The DRY principle covers many aspects of programming and we'll revisit it often.
Loops are one way of avoiding repetition.
A `for` loop allows you to repeat a block of code a fixed number of times.
You can use `for something in range(10):` to repeat the code which follows the colon ten times. The name `something` is a variable name you choose.
The block of code that's repeated follows the colon and each line has an indent.
More On The `for` Loop
The name you use between the keywords `for` and `in` in the `for` loop statement is a variable name. So, in the statement `for something in range(10)`, `something` is the variable name. Therefore, Monty fetches an empty cardboard box and labels it using the name `something`.
`range(10)` generates ten numbers, but they're not the numbers from 1 to 10. Instead, they're the numbers from 0 to 9. Python starts counting from zero!
Each one of these numbers is stored in the box labelled `something` one at a time. First 0 is stored in the box. When the loop repeats for the second time, 1 is stored in the box. Then 2 on the third iteration of the loop, and so on.
Comparing The `for` and `while` Loops
When you need to repeat a block of code for a fixed number of times, you can use the `for` loop.
When you need to repeat a block of code for an indeterminate amount of time, and let the code determine how many times to repeat depending on when some condition is met, you can use the `while` loop.
We explore several operators which return either `True` or `False`, including:
== to check if two values are equal
> to check if one value is greater than the other
>= to check if one value is greater than or equal to the other
< to check if one value is less than the other
<= to check if one value is less than or equal to the other
Indentation
A colon in Python is always followed by one or more lines which have an indent.
Lines that belong to the same indentation level need to have the same level of indent.
Indented blocks can be nested, with an indented block part of another indented block.
Lists
You can store multiple items in the same box by creating a list.
You create a list using square brackets. The items are in the square brackets, separated by commas.
More On Lists
Lists can contain items of any data type. You're allowed to mix-and-match the data types within a list, but this is not commonly-used.
You can fetch an item from the list by using square brackets which contain a number right after the list's name, such as `team[0]` to fetch the first element in the list. This is called indexing, and the number which indicates the position of the item in the list, such as 0 above, is the index.
You can also fetch a range of values from a list using slicing. Instead of including a single integer in the square brackets, you can include a range, such as `my_numbers[1:4]`. This returns a slice of the original list, starting from the item with index 1 up to, but excluding, the item with index 4. Like other range of numbers in Python, the start of the range is included but the end of the range is excluded from the range.
More Slicing
We explore more options to slice a list:
You can add a step size if you don't want to fetch consecutive elements in the list. For example: `numbers[2:10:2]` is a slice starting with the item at index 2 up to, but excluding, the item with index 10, but in steps of 2
You can omit the start of the range to start from the beginning of the list, such as `numbers[:5]` to slice from the beginning of the list up to, but excluding, the item at index 5.
You can also omit the end of the range to end the slice the the end of the list, such as `numbers[4:]` to start from index 4 up to the end of the list.
A Bit More About Lists
You can use the built-in function `len()` to find the length of a list.
You can create an empty list by keeping the square brackets empty, such as `some_numbers = []`
You can include any data type as an item in a list, including another list.
Looping Through Lists
If you want to perform an action on each element in a list, you can use a `for` loop and loop directly through the list. The `for` statement will now follow the following pattern: `for person in team_members:`
`team_members` is a list
`person` is the variable you create in the `for` statement
`person` will store each name in the list, one at a time. In each iteration of the `for` loop, `person` stores the next item in the list.
Introducing The Project
We'll use a single project which we'll build gradually throughout this chapter to introduce functions.
Here's a summary of the project's aim: You have a long list of first names. You want to write a program that chooses only those names that start with a certain letter from the full list of names.
We'll ensure we'll write code that's flexible and reusable by using functions.
First, Solve the Problem. Then, Write The Code
Before you write a single line of Python code, you should think about how to solve the problem. Plan the steps needed.
A good question to try to answer is "How would I solve this problem by hand, as a human being?" Try to break down the task into small, logical steps.
You can write the steps in plain English first. Then, when you're satisfied with your plan, you can start translating the steps written in English into Python code.
You can download the files you need in this project and add them to your project folder. They're available as a zip file as an attachment to this lesson.
You can also download the whole resources folder directly from Github. Search for The Python Coding Place on Github if you prefer that option
Getting Started
We start writing the code in small, incremental steps.
The first step is to fetch the the first name in the list using indexing. However, we'll see later that this step won't be needed in our final version.
You assign the first element of the list to a variable.
Indexing Strings
You use square brackets when you create a list, such as `numbers = [4, 6, 13, 3]`
But you also use square brackets to index a list, such as `numbers[0]` which gives you the first element in the list.
However, the square brackets notation for indexing is not reserved just for lists. You can also index strings in the same manner.
We'll talk about similarities and differences between data types in Chapter 4.
Get First Letter of First Name
You already have the first name from the list of names. You also fetch the first letter of that first name.
Next, your code needs to decide what to do next. You need an `if` statement to decide if the first letter is "P".
Looping Through the List of Names
You can repeat the steps to deal with the first name for every name in the list.
However, you don't need to manually fetch an item from the list and assign it to a variable name. The `for` loop deals with this for you.
Creating An Empty List and Adding Names To It
To keep the names you've found that start with a "P", you can store them in a list.
Create an empty list before the `for` loop starts.
You can then add names to the list using the `.append()` method. A method is a function that's associated with a particular data type. In this case, `.append()` belongs to lists.
Defining Functions
You can package some code so that you can reuse it whenever you need it in your code. You define a function using the `def` keyword to achieve this.
You choose a name for your function, and you write this name after `def`, followed by parentheses and a colon.
The block of code after the colon is the definition of the function you're creating. The block of code that makes up the function definition is indented.
Back to Monty's Story
We get back to the Monty and the room analogy we've been using.
When you define a function, you create a new room adjacent to the main room.
A function is a self-continained mini-program. Therefore, creating a new room for a function is appropriate in this analogy.
There's a door connecting the main room to the function room. This door has a label. The label is the name of the function. Therefore, Monty will find a reference to the function name and this reference is a label in a door. This tells Monty that this is a function.
When you call the function, Monty goes through the door into the function room.
When you create a variable inside a function, the variable is a local variable. This means this variable only exists within the function but it's not accessible from the main program.
Returning From The Function
You can add a `return` statement in the function to instruct Monty to take some information back with him to the main program at the end of the function.
The function does not return the box but only its contents. It doesn't return the variable but the value it represents.
You can then assign the data returned by the function to a new variable name in the main program.
To Call a Function
You define a function with `def`. This teaches the program a new command.
You need to call the function to run it. You can call a function as often as you want anywhere in your code, as long as it's after the function definition.
To call a function, you add parentheses (round brackets) after the name of the function.
Sending Information Into The Function
You can define a function so that it accepts some information when you call it. You add a parameter name in the parentheses when you define the function.
You can then use this parameter name in the function definition to refer to this information.
When you call the function, you'll now need to add some data in the parentheses.
It's best to use a descriptive name when you define a function. Often, starting the function name with a verb makes it clear what the function does.
Parameters and Arguments
A parameter is the name you use in the parentheses when you define a function and in the function definition.
An argument is the actual value you use in the parenthese when you call the function.
Therefore, "argument" represents the actual data and "parameter" represents the name, or label, you're using within the function to refer to the data.
The parameter name is the label you put on the box. The argument is the content of the box.
Defining a Second Function
You consolidate the key topic in this Chapter by defining a second function.
You use the built-in function `len()` to find the length of a string. This is the same function you can use to find the length of a list. You'll see you can use `len()` on several data types.
Adding a Second Parameter
The functions so far rely on `list_of_names`, which is a variable in the main program–a box in the main room. Functions have access to whatever is in the main room but not the other way round.
So, you can access variables defined in the main program from the function but you cannot access variables defined in the function from the main program, unless you return them.
You add a second parameter to these functions. Now, you pass the list of names to the function when you call it. The functions now work with any list of names you pass to them.
Therefore, you can use the list returned by one function as an argument for another function. So, if you want all names that start with "P" and have five letters, you can call both functions in succession, and pass the result of the first function as an argument in the second one.
Revisiting Monty
When you define a function with parameters, you can imagine a table just inside the function room you create. There's a box for each parameter on this table. But these boxes are empty. They're ready to be filled when you call the function.
When you call a function, Monty takes the arguments with him as he enters the function room. He finds the empty boxes representing the parameters. Therefore, Monty puts the arguments in these boxes.
You can read more about Monty and the White Room analogy in a series of three articles on The Python Coding Stack. You can find The Python Coding Stack on Substack
Error Messages When Calling Functions
You start looking at how to interpret error messages and the clues they give you.
You'll learn more about error messages and how we can use them when debugging in later courses if you choose to go beyond A Python Tale! You'll also learn a lot more about functions in the intermediate level courses.
Reuse
We recap the key points from this Chapter by going back to the Store-Repeat-Decide-Reuse framework.
The next chapter will return to data types and data structures.
You'll learn more about functions in intermediate courses at The Python Coding Place
Subject-Specific and Programming-Specific Knowledge
To plan and write a computer program you need two types of knowledge:
Subject-specific knowledge: You need to know the topic you're dealing with, either because it's your area of expertise or by reading and learning about it. The example I show in the video is a Python simulation of a laser beam propagating after going through a specific structure. Physics knowledge is needed to write this code. That's the subject-specific knowledge. In other programs, like writing a video game, the subject-specific knowledge is less demanding!
Programming-specific knowledge: Once you know how to solve the problem "on paper", you can use you knowledge about how to write computer programs, data types, functions, and all the "tools" in your programming "toolbox" to convert your solution into a Python program.
Iterables and Sequences
There are many categories of data types. These are not the data types themselves, like `int`, `str`, or `list`, say, but they're groupings of data types that share similar properties.
A sequence is a series of ordered items which you can fetch using the position of the item in the sequence. Lists and strings are examles of sequences
An iterable is an object you can use in a `for` loop. This means Python can work its way through an iterable one item after the other. Lists and strings are also examples of iterable data types
It may be tempting to assume that these terms have the same meaning. However, this is not the case. All sequences are iterables but not all iterables are sequences. But don't worry about this for now!
Mutable and Immutable
A mutable data type is one that can change during its lifetime. Lists are examples of mutable types. You can change any value in a list, add to the list or remove items from the list.
An immutable data type is one that cannot change once its created. Strings are examples of immutable data types. Once you create a string, you cannot make changes to it.
Note that you can delete an immutable object and replace it with a new one. This is not the same as changing the object itself.
Methods
Methods are functions associated with a particular data type
You can think of them as "attached" to an object. All lists will have access to the same methods. And all strings will have access to the string methods, and so on.
You access methods using the dot notation.
Methods Of Mutable and Immutable Types
Methods tend to behave differently when they're methods of mutable or immutable objects. Methods of mutable objects often change the values within the object, since the object is mutable. However, methods of immutable objects return a copy when making change, leaving the orignal object unchanged.
Tuples
A tuple is a data structure similar to a list. However it has one key difference: it's immutable. Once you create a tuple, you cannot change its values. You can create a tuple using parentheses (round brackets) instead of square brackets (although you'll see later on that the parentheses are not required!)
Tuples are iterable sequences. So you can use tuples in a `for` loop and you can index and slice tuples.
Dictionaries
A dictionary is a core Python data structure that contains pairs of objects. Each item in a dictionary consists of a key and a value. The key and value in a pair are separated by a colon when creating the dictionary.
You can fetch the value associated with a key by using the square brackets notation, for example `game_points["Stephen"]` returns the value associated with the key `"Stephen"` if it exists.
What matters in a dictionary is not the position of an item in the structure but the key-value associations.
Introducing Pride & Prejudice
(the project, not the book)
Imagine I asked you for a favour. I'll give you a copy of Pride & Prejudice, a notepad, and plenty of pencils. I'll ask you to spare some time to go through the whole book, keep a note of all the words used in the book and how often each word is used.
This is a thought experiment, of course! But can you write the steps you'll need to follow to perform this task?
We also deal with accessing data from outside our Python program. We introduce the built-in function `open()` to open a plain text file. Then, we read the contents of the file into a Python string.
---
You can download the files you need in this project and add them to your project folder. They're available as a zip file as an attachment to this lesson.
You can also download the whole resources folder directly from Github. Search for The Python Coding Place on Github if you prefer that option
Using The String Method `split()`
One of the string methods is `split()`. This method splits the string into a list of words. When you use `split()` with no arguments in the parentheses, the string is split at those places where there's any whitespace (space, tab, newline, and so on.)
The method acts on a string but returns a list.
Cleaning The Data
When dealing with real-world data, you'll need to clean the data before you can use it in your algorithms. Cleaning the data can mean different things for different types of input data and it also depends on what you want to do with the data.
Cleaning the data includes all the steps needed to prepare the data for your algorithm. In this example, we convert all the text to lowercase and remove all the punctuation marks.
Cleaning The Data (Part 2)
We continue cleaning the data. We use more string methods in this part. Specifically, we use `str.replace()` to replace all punctuation marks with spaces. Conveniently, all the punctuation marks are stored in `string.punctuation`.
Note that `str` is the abbreviation used in Python for the data type whereas `string` is a module with contents that can be useful when dealing with strings.
You may also have noticed that I referred to the string method as `str.replace()` in the first paragraph. I'm using the name of the data type `str`. Often in our code, we use methods directly on an object of a certain type, for example `my_name.replace()` if `my_name` represents a string.
And Now For The Main Part Of The Program
We're ready to find all the words and how often they're used in Pride & Prejudice:
Create an empty dictionary. This dictionary will contain the words and their frequencies.
Loop through the list of words.
If this is the first time you encounter this word, add it as a key to the dictionary and assign a value of 1 to it.
If you've already encountered the word earlier in the loop–which means the word is already one of the keys of the dictionary–find the current value for this word and add 1 to it.
Writing The Results To A CSV File
We've seen how to read in data from the real world and bring it into your Python program. Often, you also need to export results from your program to a format that exists outside Python. In this example, we create a spreadsheet using the `.csv` file format.
The `.csv` file format is the most basic of all the spreadsheet formats. It is a text file that has commas separating values and newline characters to show when to start a new line.
You can create a write-enabled file by using `open()` with the `"w"` argument as its second argument.
Looping Through Dictionaries
We've seen that dictionaries are mutable data structures. They are not sequences, since we cannot index them with an integer that represents the position of the item.
Dictionaries are also iterable. You can use them in a `for` loop. When you loop through a dictionary, Python iterates through its keys. It ignores the values.
However, you can loop through the key-value pairs using the `items()` method. This is a dictionary method.
A Few Final Things
We conclude this chapter with a few additional things:
Tuples don't need parenthese. As long as you use commas to separate items, you can omit the round brackets.
You can either use the variable name representing an object or the object directly anywhere you need to use the object.
Data structured like tuples, lists, and dictionaries can contain different data types, including other data structures. There are some limitations on what can be used as a key in a dictionary, but you can ignore these for now.
When opening files, you can use the `with` keyword which opens and closes a file for you, so you don't need to remember to close the file!
We conclude the main chapters of A Python Tale, but there's an Epilogue with an extra project, too!
In A Python Tale we have covered how to store data, repeat blocks of code, get your program to decide what to do, and how to reuse code using functions.
We also dealt with several data types and data structures, including integers, floats, Booleans, strings, lists, tuples, and dictionaries (and one or two more along the way!)
There's more at The Python Coding Place
You can read more about Monty and the White Room analogy in a series of three articles on The Python Coding Stack. You can find The Python Coding Stack on Substack
You can read more about Monty and the White Room analogy in a series of three articles on The Python Coding Stack. You can find The Python Coding Stack on Substack
You can read more about Monty and the White Room analogy in a series of three articles on The Python Coding Stack. You can find The Python Coding Stack on Substack
You can carry on your Python journey at The Python Coding Place
A different way of learning to code in Python. This course takes you through the basics of programming in a teaching style that's friendly and relaxed.
The focus is on clarity and really understanding what's going on.
I've been teaching Python coding for a decade and I'm the author of The Python Coding Book (just ask Google for a "python book"!)
My teaching style is different. Try out the first few lessons and if it's your style, then we'll be together for a many hours.
No prior experience of Python or coding is required. This is a beginner's course.
Or perhaps you're not a beginner, but you've done a bit of coding in the past but didn't carry on. It wasn't you, it's likely you didn't find the resources that speak directly to you. I can't promise my style is what you're looking for, but you'll know after the first few lessons!
In this course you'll learn:
How to apply the key principles and mindset for communicating with a computer through programming
How to repeat blocks of code using `for` loops and `while` loops
How to store data using variables and using various data types
How to define your own functions to re-use code
How to use data structures including lists, dictionaries, and tuples
How to read data from external text files and spreadsheets and write data to these file formats
How to apply best practices when coding
This course will teach you all the fundamental tools, of course, but more importantly, it will teach you the right mindset for programming. This is just as important as learning all the programming techniques—if not more important.
And you'll also meet Monty, the main character in an analogy I love which I'll share with you in this course—trust me, this analogy alone is worth your time as Python programming will make so much more sense…