These are sample programs used and created in lecture for CS303e.
Topic 1: Python Basics
my_first_program.py (Classic "Hello World!" program.)
Topic 2: Variables, Input, Processing, Output, part 1
Topic 2: Variables, Input, Processing, Output, part 2
Topic 3: Conditional Execution, part 1
Topic 3: Conditional Execution, part 2
Topic 4: Repetition (loops, iteration), part 1
Topic 4: Repetition (loops, iteration), part 2
newton_square_root.py (using Newton's method to determine an approximation of the square root of a number.)
generate_bmi.py (Generate BMI for various heights and weights)
Topic 4: Repetition (loops, iteration), part 2
loop_examples.py (various examples of using loops to solve problems)
Topic 5: Functions, part 1, Wednesday
function_examples.py (functions that appear in the slides)
function_Examples_lecture.py (functions developed in lecture)
Topic 6: Files
line_count.py (Demonstrate open and reading from files.)
write_coin_flips.py (Demonstrate writing to a file.)
write_read_numbers.py (Write to a file and then read from it.)
Topic 7: Lists, part 1
Topic 7: Lists, part 3
list_examples_2.py (many functions with examples of solving problems with lists)
Topic 8: Lists of lists, part 1
game_of_life_part_1.py (First part of text based version of Conway's Game of Life)
Topic 8: Lists of lists, part 2
game_of_life.py (Completed version of Conway's Game of Life)
Topic 9: Strings
error_check_int.py (Function to ask user for a non negative int and keep asking until valid int entered.)
Topic 10: Dictionaries and Sets, part 1
word_count.py (Determine the frequency of words in a file and print the words with the highest frequency.)
Topic 11: Object oriented programming
Circle.py (Example of defining a new data type in Python)
circle_client.py (A class that uses the Circle class defined above.)
Topic 12: Recursion
directory_space_example.py (Finding the space (memory) taken up by all the files in a directory including all its subdirectories.)
recursion_examples.py (Examples of simple recursive methods.)
Topic 13: Sorting and Searching
searching_and_sorting.py (linear search, binary search, insertion sort, examples of calling build in list searching and sorting methods)