Beginner's Guide and Instructions to Programming in Python using the JupyterLab IDE
- This tutorial is based on the following website. No tutorial is perfect, so please feel free to email me. There are multiple ways to do things. Like anything, learning how to program takes practice. However, a big flaw in computer programming courses is that there is no practical aspect. Below is a summary in tabular format.
- This tutorial is based on this website. Each program builds on the other, so I recommend going in order. Because computer programs can escalate in size, I periodically write reviews that summarize the previous section and I try to keep the text of the summary to a single page. I made PDF versions of the programs. The best way to learn how to program is to hand type these programs and change them around. Therefore, I have made PDF versions of the programs in addition to the Python language versions.
Section #1-Comments, Print Statements, Variables and Concatenation
|1||Comments||Link||# Style #1 for line comments
''' Style #2 for block comments '''
|None||001-Comments.ipynb||I put this first because I put comments throughout
the programs, so that students understand.
|2||Print Statements||Link||print("Some Text") or
use of a backward slash \
|None||002-HelloWorld.ipynb||This is a classic beginning program Hello, World!.
You learn how to output characters in the console using
the print('output") Python command. You can put single
quotes within double quotes and vice-versa. The backward
slash (i.e., \) can be used to output invisible characters such
casting: int(), str() and float()
|None||003-Variables.ipynb||You learn about three different types of variables, namely string
(str), integer (int), and real numbers (float). You also learn how
to convert a variable using a process called casting.
|Similiar as previous, but will
demonstrate a computer concept
|None||004-Variables+Con.ipynb||You learn how to concatenate your output. Concatenate
essentially means to combine. You can combine using a plus
(i.e., +) or a comma.
|5||Short Review of
|All the Above, but shorter||None||005-Short_Review.ipynb||Reviews the above in a shortened and less wordy format.|
Section #2-Making decisions with the Python language using if-then-else statements and comparisons.
|Link||if, elif, else||None||006-If-then-else.ipynb||In this part, you will learn how code is put into sections. You will also learn how Python language
makes decisions through if, elif and else commands.
Boolean, equivalent (equals to)
|True, False, ==||None||007-Booleans.ipynb||In this part, you will learn about booleans. Basically, booleans are things like true or false, yes and
no. You will also learn about the Python equivalent of "equivalent to", which is double equals ==
Comparison operators (CO) and
Logical operators (LO)
>,<,==, >=, <=
and, or not
|None||008-Operators.ipynb||This part teaches you about comparison operators (i.e, comparing two values) and logical
operators. We will also talk more about booleans.
|9||Short Review of Exercises 1-4 and 5--8.||None||009-Short_Review.ipynb||This short review encompasses everything from exercises 1-4 and 6-8. The program
has concatenation, type() function, if-then-else statements, comparative operators and
Section #3-Arrays and Modules ⇒ Plotting with Matplotlib
- I feel the best way to learn computer programming is to do something interesting and useful. You will need to know the above exercises 1-9 very well before you proceed. Computer programming builds on itself. If you prefer a slower introduction, I would recommend this tutorial. I have added a priority section to give you an idea of how you should prioritize learning Python. Some things you should know and others you can just be aware of it as you need it such as the Built-in Python Array Methods.
|Plot Output||Python Program||Comments|
|10||Basic Built-In Math
be aware of %
|+,-,*,/,%,**||None||010-Basic_Math.ipynb||With these exercises, you will learn basic math functions with Python.|
|None||011-Arrays.ipynb||This exercise teaches you the basics of Python arrays. To plot data, you need to
know arrays because they are the basis of all datasets.
|know the append() method.
|None||012-Array_Methods.ipynb||Set the Method2Try variable to the following programs:
1) append() method
2) copy() method
3) clear() method
4) count() method
5) extend() method
6) index() method
7) insert() method
8) pop() method
9) remove() method
10) reverse() method
11) sort() method
The 012-1-Append().py is only part of the 012-Array_Methods.py to show how to separate it from the larger program.
range() data type
tuple() data type
|know len() and
range. Be aware
of the rest
|None||013-Array_Functions.ipynb||Set the Function2Try variable to the following programs:
1) len(list1)- Gives the total length of the list.p>
2) max(list1)- Returns item from the list with max value.
3) min(list1)- Returns item from the list with min value.
4) list(tuple1)- Converts a tuple into a list.
5) range(start,stop,step) - Make a list of numbers with certain parameters
|know np.array() and
be aware of
|None||014-Introduction_to_Modules.ipynb||In this exercise, you will learn what modules are and then NumPy
module functions np.array() and np.matrix() that you need for the
|15||Python Plotting Module:
|Be aware of the
different plots available
in the Matplotlib
|015-Matplotlib_Module.ipynb||Run the programs in each cell
1) Line Plot
2) Scatter Plot
3) Line and Point Plot
4) Dashed Line Plot
5) Line Plot with Axes Labels
6) Line Plot with Axes Labels and Title
7) Line Plot with Labels with Color
8) Line plot with Labels and Grid
Section #4-Loops and Loading Data
|know it||Link #1||Dictionary Data Type
|016-Dictionaries_Arrays_Loops.ipynb||Run in each cell
1) This program will print out the list of names using the for loop 2) List of names from a simple dictionary using a for loop
3) List of names from a complex dictionary using a for loop
4) Using a for loop with a range of numbers
5) Learn about a new type of loop called a "while loop"
6) Same as 5 except a different style of doing an Increment.
Nested Loop (Loop within a Loop)
7) Uses a nested loop for a two-dimensional array
8) Uses a nested loop for a two-dimensional NumPy array
9) Uses a nested loop for a dictionary variable type. This has a similar output to #3
|17||Reading, Parsing and Saving
|be aware of
|017-Reading_and_Parsing_Files.ipynb||Run in each cell:
1) Display the file line by line using readlines() command.
2) Display a file all at once.
3) Same as 1, but use replace() function to remove hidden characters. Also, learn the strip() function that removes space at the beginning and end of the line.
4) Same as 2, but use replace function to remove hidden characters.
5) Similar to 4, learn how to split file into sentences using the split() function.
6) Similar to 5, but splits the file into words.
7) This is a more sophisticated program that makes a frequency. dictionary of text. Uses functions split(), lower(), strip() and replace().
8) Same as 7, but we are going to save the output using the csv module.
References and Notes
- You can block comments with three double quotes (i.e., ") or three single quotes (i.e., ').
- In Python 2.x versions, the command was print "Some Text" or print 'Some Text'
- Hello World is classically the first program that someone writes. See https://en.wikipedia.org/wiki/%22Hello,_World!%22_program
- Operator in simple language is something that does "operates" on something else.
- np is shorthand for numpy, when you import numpy as np.
- plt is shorthand for matplotlib.pyplot