Home CS303E

Python Example Programs

CCN.py - credit card validation. practice with lists.

substringPrint.py - Read a string from the user, and print all substrings of it.

ChristmasTree.py - use nested loops to print a Christmas tree

triangle.py - use nested loops to print a right-justified triangle

Camus.py  --  simple print statements

SentLoop.py  -- sentential loop (while loop)

Song.py -- function example (used to print the "happy birthday" song)

EmptySentinel.py -- read and process numbers, and stop when the user hits enter rather than entering another number

SumDig.py -- read an integer from the user (validate the input) and print the sum of the digits in the number

PrintOneCharAtTime.py -- read a string from the user, and print it, one character per line

Prod.py -- call a function inside a loop

ExamAverage.py - use a sentinel loop to read exam scores, and then compute the average. Uses a function to compute average.

PrintString.py -- string indexing example

Print10.py -- simple example of functions and use of range()