Welcome

In this section of the Nathan Tech website, it is our intension to provide you the ability to start from knowing absolutely nothing about programming, to being able to use python compitantly for any project you choose, simply by following these tutorials.
Each tutorial is roughly 15 minutes in length, and will walk you through step-by-step explanations, with frequent recaps of each part.
the tutorials are divided into two sections:
Each tutorial is available for download and may be freely distributed providing it is clear that we, Nathan Tech, are the owners of, and recorders of, the tutorial and that the tutorial remains unmodified and free.
Please provide feedback through our Contact Form.

Section 1: Learning.

1: Introduction

A quick introduction to the language, including downloading and installing.

Download
Text script>hello there, ladies and gentlemen.
My name is Nathan smith, and today I am going to be doing a hopefully extended set of tutorials on the python programming language.
For those who do not know, python is perhaps one of the easiest programming languages to learn to help make you a developer of software, server clients, games or pretty much anything.
It's flexible, it's pretty dynamic, and its easy to learn at the end of the day.
And that is what these tutorials are about Getting you on your feet, with python.
The first 6 episodes of this series are going to be focussed on learning the language itself, then in those following we will be talking about building a simple game.
So lets get started.
First of all, we are going to talk about how to obtain python.
Python can be obtained from python.org.
Nice and simple, go to their website, click download, job done.
There are two versions of python available at the time of this recording, python 2 and python 3.
We will be working with version 3, because as of January 2020, python 2 will no-longer be supported.
So, once you've downloaded python 3, you will...
In this recording we will be using the executable installer, there is a web one available, but we will walk you through the executable.
So up on my screen at the moment I have a question of "What items I want installed."
I have the following items checked:
documentation,
pip,
tcl and idle,
python test suite,
py launcher
and for all users.
I'm going to click next, it did come up by default but I'm not sure if that is due to me already having python.
So next, and now we have a screen in which it is asking some more questions.
You definitely want to associate .py files with python, create shortcuts you may want, and add python to environment variables you certainly want.
Compile prestate libraries is up to you, I personally check it.
So!
Click install and off it goes.
So while that installs, I'll just talk to you about these tutorials, what they mean, and what their intention is.
The tutorials are roughly 15 minutes long, and will basically hopefully be able to get you on your feet with programming.
Code samples will be provided, like in the next tutorial for instance, but they will also teach you how to think for yourself in these situations.
I'm just going to talk through how I think of the language, throwing in some little stories that hopefully should keep things interesting and make it easier on you.
This should help you visualise this language in an easy way.
Python is an object orientated programming language, for those who care about such things.
If you don't, I'll talk about it later, don't worry.
What else can I tell you.
So python has been around for quite a while, and is a tabbed language.
This means that indentation is very important, which is something we will cover later on.
These tutorials were made by a visually impaired person, that's me, and as of episode 7 will be targeted more at how to make an audio game.
We will touch, briefly, on visual elements, but our main emphasis will be on the audio aspects.
To that end, we will be focussing on pygame, which is a fully-featured gaming systems as of the 7th episode.
You may hear background music in the tutorial, which I claim no ownership for and is to help provide entertainment while I ramble on.
If you have any feedback about these tutorials, good, bad or otherwise, please let me know through the contact form.
You can find the form at https://nathantech.net/contact.php.
I am providing these tutorials for free, and to download should you wish and as long as you make it clear that I, Nathan smith of Nathan Tech, am the voice being heard, and you have not made me sound any more stupid than I do already, I have no problem with you playing them as and how you see fit.
beauty is in the ey eye of the beholder, and I can't see it, so we're all good!
If there are things that you would like these tutorials to cover that they do not already, please let me know!
These are for enspiring, or aspiring programmers who hopefully will be enspiring.
So the idea behind these tutorials is you can sit back, knowing nothing of programming, pick them up and get started.
to use python you will need a basic understanding of the command line however these tutorials will teach you that as soon as this installation finishes!
the command line is a windows built tool, I believe on mac it is called terminal.
You can open it on windows by pressing windows+r, then typing CMD.
you will get a window that looks a little like "C:\windows32\users".
It looks fancy, trust me on this!
you will do part of your innicial tests in this window, such as running uncompiled scripts from here, so it pays to know how to use it.
there are several ways o navigate this window, depending whether you are doing it visually or with a screen reader like JAWS or NVDA.
From my experience when using voiceover you interact with the window and then use voiceover left and right to review the text.
With NVDA, you use the NVDA cursor to navigate through the window.
For example, I use NVDA up and down arrow.
Don't be scared by the command line, it's nice and simple!
Lets talk about two basic commands you will use a lot.
Command number 1: cd.
Open up your terminal and type cd then hit enter.
CD stands for change directory.
This will just take you to the directory you are in, for intsance: "c:\users\bob."
If we wanted to go into documents, we'd do: "cd documents" and hit enter. If I can spell correctly.
You can go up one directly by typing "cd .."
Fancy!
It's a very useful command as it enables you to navigate to your scripts once they are made.
how do we test python is installed?
The most important thing for you to know is how to run python from the command line.
You do this by typing python in your command line window which for me, after a pause, showed "python 3.7.3" which was the version I used at the time of recording.
First time I was ever up-to-date in my life!
We're going to close that by pressing control z on windows, or command z on mac.
Congratulations, you have just launched your first python window!
Well done, I hope you feel warm and fuzzy.
So how do we close command line? type exit.
that pretty much concludes this introduction, I can't drag it on for 15 minutes.
All feedback is welcome.
thank you for listening, this has been Nathan smith of Nathan Tech.

2: Variables

We talk about the 6 most common variable types and the print command.
Download
code snippets print("hello");
name="Nathan"
print("hello "+name)

Text script>Hello there, ladies and gentlemen it is me, Nathan smith of Nathan Tech as you are no doubt expecting by now and welcome to the Learning to program in python tutorials, number 2.
In this tutorial we are going to be learning about variables, which are the fundamental of any programming language.
First of all what does the word variable mean/
Lets break it down.
in the word variable you have the word vary, and that is what we are going to focus on, because able is just so boring, and who wants to talk about Able anyway.
Vary means to change.
So a variable is a piece of data that can change.
for example, and the example we will use throughout this tutorial is a person, like my good self.
A variable about me might be my age, because that can change every second, of every minute, of every hour of every day. I try not to think about me getting old that fast though.
In this tutorial we will cover some of the most commonly used variable types, but not all of them. there are too many to name, but we will teach you the fundamentals.
Lets load up a python terminal in the way discussed in tutorial 1.
Lets talk about variable types:
you may have heard, if you have experience in programming the term data types, in other words, what a piece of data is.
they define what type of data you are working with.
In other languages you have to define what type of variable you are using, for example, if I wanted a number I might write:
int my_number=1;
In python however, you simply write:
number=1;
this is why python is so flexible and easy!
This however can also make it slightly dangerous, as you can accidentally change your variable type.
First of all lets cover numbers.
Numbers are split into two categories:
intigers
and what is commonly refered to as floating points, or decemal numbers.
As you may have guessed an intiger is a single, hole number like 1, 2, 3, 4 or 5.
To test this in python simply type:
number=1
you'll get a couple of greater than signs, and nothing much else.
To tell us about this variable though, and to make sure we've defined it, lets use a function called print.
Print is a built in python command, but don't worry too much about that you'll learn about those in a later episode.
For now though, simply type:
print(number)
Note the punctuation in the above line, it's very important!
the print statement does exactly what it sounds like. It will print something to the command line.
In our case, it tells us the number 1.
If you want to find out exactly how this is done, feel free to google it, delving into print further is above this tutorials purpose!
So moving swiftly on, we'll cover floats, or doubles.
Call them what you will, they're decemal numbers like 3.1.
Try making a float like this:
number=3.2
print(number)
All pretty simple!
When considering the subject of a person, perhaps one of the most important things about them is their name.
My name, for instance, is Nathan smith of Nathan Tech, though it doesn't say "of Nathan Tech" on my birth certificate!
This would be a string.
A string is a collection of characters. It can be one character, 10 characters, or a string as long as you like. providing you have the memory for it.
How long is a piece of string after all, right?
Insert awkward silence at bad joke.
So how do we define strings in python? Pretty simple, we use quotes like so:
name="Bob"
You could also do:
name='Bob'
Most programmers prefer the second way, due to things we will cover later.
print(name)
Hey look! It's Bob.
the final simple variable type that we are going to cover is boolean. Big fancy word!
Boolean means true or false.
Important! Python requires you to capitalise the words True and False.
Lets define a variable called boy:
boy=True
If we do print(boy) we get true.
If however we do:
boy=true
We get a traceback that says "name true is unknown."
this is python's way of telling us we refered to a variable that does not exist.
In the second part of the tutorial I would like to cover two slightly more complex variable types.
they're not complicated as such, just more interesting and fun.
the first of these is lists.
A list is defined with square brackets, like so:
l=[]
A list can contain other variables, like numbers or floats, or strings, or even other lists! Like so:
l=[1, 2, 3, 4, 5]
Commas, as you may have guessed, separate elements of a list.
Lets type:
print(l)
Now, using our variables from earlier, lets make a new list:
l=[number, name, 3, 4, 5]
print(l)
This may not seem complicated, and it really isn't, but now lets up it a step.
You can actually store lists in lists, these are refered to as multi-level arrays.
We won't really use these, but allow me to explain them to you anyway.
Imagine a room.
Inside this room you have boxes.
If this was in code form, the room would be the master list, the boxes the next list the stuff inside the boxes the next list, and so on.
Here is a visual representation, if it helps:
box1=["apples", "bananas", "carrots"]
box2=["chocolate", "more chocolate", "a lot of chocolate"]
box3=["chicken", "beef", "pork"]
room=[box1, box2, box3]
print(room)
[["apples", "bananas", "carrots"], ["chocolate", "more chocolate", "a lot of chocolate"], ["chicken", "beef", "pork"]]
Now you have a multi-level array.
Well done!
the final, and perhaps most interesting, of variables we are going to touch on is called a dictionary.
quite a lot of people have heard of this, but not many understand them and they can get quite scared of them, in fact.
It's my job to make sure you understand them, and can educate the masses!
I'm going to explain these in a way you can hopefully understand.
First, lets define an empty dictionary which is done in braces like so:
d={}
Now. Here is how I am going to explain dictionaries.
Imagine, if you will, this dictionary represents my good self. Or your good self.
What would this dictionary need?
Well for starters, a name, gender, age, obviously not a good looking state, as that would always be set to true. Obviously!
but lets go with that for now.
This is where python dictionaries come in handy.
Dictionaries contain a key and a value.
Remember those terms, key, and value.
Lets define our first piece of information in this dictionary:
We will do:
d["name"]="Bob"
note the punctuation.
What does this mean?
Well, we have d, which is our dictionary. then we have square brackkets, inside which is the string "name".
This is the key.
So here we have key = value.
And that is what makes up a python dictionary.
In this case, the key is "name" the value is "bob".
This is why so many people like python dictionaries, because they're easy to organise!
We can check the value of this, too!
d["name"]
this will show us the value for the key name. We can also do:
print(d["name"])
How useful is that?
Very!
Because now, we can also define age in the same way.
d["age"]="none of your business"
Absolutely fantastic.
Python can be used in many things, for example score boards.
Scoreboard={}
scoreboard["bob"]=10
Obviously this can be done in other ways, too, but it shows you at least an example!
this covers the fundamental variables you will use most often in python but as a last key term, lets run over a final use for print.
First of all lets define:
name="Bob"
Les do the following:
print("Hello "+name)
This produces "hello Nathan".
There are a few things to note about this though.
Try out the following:
print("hello "+123)
did you get a traceback/
Can not concatinate string and int objects.
This means it can not add an int to the end of your string.
However, if you do:
1+2
This gives us 3.
yes, python can be your pocket calculator.
there are some ways to do conversions in python, which are listed above this text in the snippets section.
Ultimately, once you know them, you know them and there's not much more to know.
As a final ending to this tutorial, lets do a little more variable manipulation.
age=10
age=age+10
Now why have we done this?
What does it do?
First of all, you have:
age+10
age is 10, 10 + 10 is 20.
So why do we have the age= part?
If we just wrote: age+10 python would not store the result.
It would lose it. what a loser!
by writing: age=age+10, we tell python to take the value of age, which is 10, add 10 to make 20, and store it back in the age variable!
You can now see, if you type:
print(age)
that age does indeed equal 20.
I've run out of time for this episode, but hopefully you found it useful and are now thinking of other ways that you can apply this knowledge.
I look forward to seeing you in part 3, and thank you for listening.
This was Nathan smith of Nathan Tech.


3, if, elif, and else

In this tutorial we go over the different ways to use the if statement.
Download
Code Snippet
number=1
if(number==1):
 print(number)

number=10
if(number>5):
 print("nice")
elif(number<3):
 print("rubbish")
else:
 print("not bad")

score=10
if(score<2):
 print("What game are you playing?")
elif(score>=2 and score<7):
 print("not too bad.")
elif(score>7):
 print("great score")

score=10
if(score>3 and score<5):
 print("not bad")
elif(score>=5):
 if(score==10):
  print("NICE!")
 else:
  print("not bad")
else:
 print("rubbish!")

Text script>
Hello there and welcome yes, it is I Nathan smith of Nathan tech, back again with another tutorial for learning python.
In this tutorial we intend to cover one or two things we missed out, ahem, in episode two, as well as a new funky statement.
Lets do a quick recap.
Last time, we touchd on variables and the variable types available.
We also experimented with print.
this time, lets start off with a personal coding technique of mine.
it's what I call, "How to use a text editor."
First of all lets talk about what a text editor is.
A text editor is a program you use to write text, like notepad, notepad++, word, wordpad, ETC.
Not all are suitable for writing code, however.
For example, word is probably not your best choice.
I personally choose notepad, but notepad++ is a specific code editor and what ever one you choose to use is up to you.
If you want, at this point, create a folder in your documents and call it something.
In this, put a file in here of your choice.
It should be noted, the file must be a .py extension, not a .txt.
you can do this by opening a new file, saving it, and in the name field put quote, main.py, quote.
"main.py"
that will save nicely, and you can continue onwards.
In this tutorial we are now going to talk about what it means to work with a tabbed programming language.
In my personal experience there are two types of language.
One is tabbed, one is not.
C, for example, uses one that is enclosed in braces.
In c, you'd define a function like this:void main() {
code
}.
In python however, this code looks like:
def main():
 indented code.
this sounds a little complicated, but it really isn't!
It actually helps keep track of what code is in what place, making debugging that bit easier!
It is important here as we are going to start the next bit, statements.
the if statement is a built in function of python.
We will touch on what that means later.
To that end, we call functions using parens.
You've seen this earlier with print.
print("hi")
The print statement is a builtin function.
As you can see, the word print is the name of the function, and the parens contain arguments.
Arguments tell functions what to do, pretty much.
If is another one of these functions.
this is where I recommend you use that file, because you will find it easier to keep track of indentation and such.
Before we continue, allow me to touch briefly on how to run a python file.
The way you do this is open up your terminal or command line.
then change to the directory your file is in, for example:
cd documents
then
cd tutorials.
to run a python file simply type python followed by the name of your file.
python main.py
so!
Back to our original topic.
Lets define a variable first.
number=1
First, lets write a very simple if statment.
if(number>1):
We've written if, which is the name of the builtin, left paren, so we're giving arguments, number>1. Is the number greater than 1? IE, if the value of number is greater than 1, then do the code that follows.
Python knows what code is related to this if function, because we indent it.
if(number>1):
 print("hello.")
If you are in the terminal, hit enter twice.
If not, run the file.
If you do so, you'll see nothing has happened!
Why?
Because numberis equal to 1, not greater than 1.
so how do we say in python, if number is equal to 1?
if we wrote if(number=1), python would get a bit confused.
Instead we use two equal signs, like so:
if(number==1):
 print("hello!")
Now run this code, and see what you get.
We got: "hello!"
This is why running is a file becomes useful, as you can quickly adjust your code without typing it out again.
Lets introduce another element to this code called else.
if(number==1):
 print("hello")
else:
 print("huh?")
Notice how the if statement and the else statement have the same indentation? this tells python that they are related to each other!
If this was a list of if statements, like this:
if(number>1):
 if(number==2):
Python needs to know which if statement the else refers to.
that's where the indentation comes in.
Feel free to play around with this and get used to it.
we're going to introduce a final element to this now called elif.
this literally means else if.
It would go something like this.
If I gave you an instruction, if number is 1, do this, else if it is 2, do this, else if it is 3, do this, if none of these? Don't bother.
Lets put this into python code:
if(number==1):
 print("1")
elif(number==2):
 print("2")
else:
 print("not 1 or 2.")
If you'd like to run this, and set your number variable to 1, you will see the end result is 1. If you set number to 2, the result is 2.
Where might this come in useful/
Here's an example!
score=10
if(score>10):
 print("Woohoo, great score!")
elif(score<5):
 print("What game are you playing?")
else:
 print("That's decent, I suppose.")
Why is the else statement important here?
Because we have if the score is greater than 10, or less than 5. But what if my score is 8? That's where else comes in.
Personally I think 10 is a great score, but that's just me.
Many things can be put into an if statment, but the fundamentals are:
== means the same as
>= meaning greater than or equal to
<= meaning less than or equal to
> meaning greater than
< meaning less than.
Lets put these into practice:
if(score==10):
 print("You got 10.")
elif(score>10):
 print("Niiiiice!")
elif(score<5):
 print("That's rubbish. what are you doing?")
elif(score>=5 and score<=10):
 print("not too bad.")
else:
 print("Decent. I guess...")
Lets talk about the and and or that we used in the above statement.
The and and the or allow you to define extra items of the if statement. Like this:
if(score==10 or score==11):
 print("Nice")
Here is another example:
if(score>=8 and score,=11):
 print("Nice.")
elif(score>11):
 print("Really nice!")
I hope you have enjoyed this tutorial and we will go over it a bit more in the next episode.
thank you for listening, this has been Nathan smith of Nathan Tech.

4: loops

In this tutorial, we introduce the for and while loop, as well as a couple of builtin functions. Download
number=1
while(number<10):
 print(number)
 number=number+1

number=1
while(number<10):
 if(number==5):
  break
 print(number)
 number=number+1

l=[1, 2, 3]
length(l)
range(3)

l=["bob", "freddy", "jimmy"]
for x in l:
 print(x)

l=["bob", "freddy", "jimmy"]
print(l[1])
for x in range(len(l)):
 print(x)


l=["bob", "freddy", "jimmy"]
for x in (range(len(l)):
 print(str(x+1)+" "+l[x])

5: functions

We introduce how to use functions, and explain why they are useful.
Download
def test(x):
 print(x)
def sum(l):
 total=0
 for x in l:
  total=total+x
 return total
def inrange(px, ex):
 n=px-ex
 if(n<3):
  return 1;
 else:
  return 0

6: Dir and getting help

This tutorial covers how to google your problems, how to understand tracebacks, and when not to ask silly questions.
Download

7: Modules

The final in the series, this tutorial covers modules, the import command, the pip command, and an example of the time module.
Download
import time
time.time()
time.ctime()
pip install clipboard
pip uninstall clipboard
import clipboard
clipboard.copy("hello")

Section 2: Applying.

Coming soon!