Sample PYTHON Scripts

The tables below contains sample PYTHON scripts for you to study. Feel free to download any or all of them. Most are short and show how to do one or two things that you will need to know how to do. Occasionally, I will include more complicated scripts that show how to use many of PYTHON's more advanced features. I will add more scripts to this section as time permits.

Simple PYTHON Scripts

comments.py This script shows how to comment lines and when to use comments.
comparisons01.py This script shows how to get numerical data from the user and the various ways that two integers can be compared in PYTHON.
comparisons01a.py This script shows how to get numerical data from the user and the various ways that two integers can be compared in PYTHON. rewritten as a function.
dateFunc01.py dateFunc01.py contains a function which imports PYTHON's datetime module and does some error checking. The purpose of the function is to find the number of days between two dates. callDateFunc01.py shows how to use it.
doubleInt.py This script shows how to get numerical information from the user which is a string, convert it to an integer, perform some math and reformat it for display.
forBurp01.py For loops at play.
for-letter01.py Take apart a word entered from the keyboard and print it out one letter at a time using a for loop.
formatStrings.py formatStrings.py shows different ways that numerical data can be formatted for printing.
gradeCounter.py This script demonstrates the use of a while loop.
import.py This script shows how to import modules and use functions and methods that they provide. Specifically, this script imports the sys and string modules.
os01a.py This script demonstrates how to get information about some aspects of your operating system (whichever one that is) using the os module. The last several calls show you how to run programs (in this case NOTEPAD and Adobe ACROBAT READER from a PYTHON script.
quotes01.py PYTHON allows you to format string values with different arrangement of quotation marks. This script shows how.
squared.py squared.py contains a single function which squares an integer. The script callSquared.py shows how to call it as a module and use the function.
stringFun.py This script show how to join (concatenate) several string together and how to take them apart.
time.py This script shows some of PYTHON's time and date function.

GUI scripts using Tkinter

listdir.py This is one way to create a list box in PYTHON. Based on a script from Core PYTHON Programming
tkTest01.py This script creates a root window with a label, slider and button. The slider allows the user to change the size of the font in the range of 10 to 40 points. The button exits the program. Based on a script from Core PYTHON Programming