Richard's Python 2020 Page


Richard Ricardo's example page of Python programming language.

0. Download and Install Python

Objective Description
Download & Install

Go to Python.org

Download the latest version for Windows

Create folder "python" in in c: drive, c:\python\

Double-click on the downloaded .exe file to install python for windows

Choose Customize install > Next > Change "Customize install location" to c:\python\

Note: Python is case sensitive.

Write the first program using IDLE

- do this one, easiest

Search for IDLE, OR Windows Icon > Python > IDLE
Pin to taskbar

Open IDLE, you will see "Python --- Shell"
Type:

print ("hello")

Note: IDLE is Python’s Integrated Development and Learning Environment.

To save file...

Create folder c:\temp\python

Show File Extensions in Windows - video 00_002

In IDLE > File > New File

File > Save As...

c:\temp\python\helloworld.py

Type:

print ("hello world")

File > Save OR Ctrl-S

Run > Module or F5

Write the first program using Interactive Shell

Search for Python, OR Windows Icon > Python > Python

Type:

print ("hello")
Write the first program using notepad++

Do not try this if you have not programmed before

Install notepad++ (if you have not done so) - video 00_001

Show File Extensions in Windows - video 00_002

File Explorer > go to c:\temp\python\

Create new text document, name it cmd.bat, put in the following...

cmd.exe

Double click on cmd.bat

Type the following (same to a text file, commands.txt, for future use)

set path=%path%;C:\python

Type this to run file

python helloworld.py
Others / Extra Dr. Coleman's notes 1 for Python Coding Camp

 


1. Variable

Objective Description
values, comments, variables, strings, type casting

eg001.py (eg001.txt)

right-click on file > Edit with IDLE

user input eg002.py (eg002.txt)
string formatting, control string eg003.py (eg003.txt)
Others / Extra - Turtle graphics Dr. Coleman's notes 2 for Python Coding Camp
python_session2_turtle.py (python_session2_turtle.py)
Others / Extra Dr. Coleman's notes 3 for Python Coding Camp

 


2. Arithmetic Operation

Objective Description
expressions, arithmetic eg004.py (eg004.txt)
mixed type expressions eg005.py (eg005.txt)
simple program example

eg006.py (eg006.txt)

Fahrenheit to Celsius, Celsius to Fahrenheit

 


3. Conditional Statement

Objective Description
boolean expressions, if .. else .. statements eg007.py (eg007.txt)

and, or, not
pass statement
elseif
nested if

eg008.py (eg008.txt)

 


4. Iteration

Objective Description
while loop
Yes or No, uppercase

eg009.py (eg009.txt)

while loop
enter numbers

eg010.py (eg010.txt)
for loop eg011.py (eg011.txt)
nested loops eg012.py (eg012.txt)
GAME - guess my number 1 to 10 game001.py (game001.txt)

 


5. Functions

Objective Description
using function eg013.py (eg013.txt)

using math, time functions etc.

eg014.py (eg014.txt)
writing functions eg015.py (eg015.txt)
writing function turtle graphics eg016.py (eg016.txt)
Others / Extra - Turtle graphics

Dr. Coleman's dice.py (dice.txt)
- generates a pair of randomly chosen dice
- introduce functions
- random library and if..else

Dr. Coleman's maze.py (maze.txt)
- draws a maze
- lets the user navigate through it using the arraw keys
- does not prevent walking through walls
- if..else, for loops, functions, hexadecimal numbers, bitwise operators

 

 

 


20. Others

Objective Description
Others / Extra - Turtle graphics

Dr. Coleman's pong.py (pong.txt)
- classes and objects, functions, if..else, while, boolean, keyboard events

Other / Extra - matplotlib Dr. Church's Game of Life