Tue Oct 18 15:27:08 EDT 2022

These are the simple Python programs used in class, plus a few others. If you read them and (much better) play with variations, it will help you to figure out what's going on in programming, and the two Python labs will be easier too.

These were originally written by Francisca Weirich-Freiberg '20 based on JavaScript models and subsequently fiddled by bwk, mostly to make better use of Python 3.

add2.py: add two numbers

add2f.py: add two floating point numbers

addup.py: add up numbers until 0

area.py: computes area of circle from radius

areafcn.py: computes area of circle with function

firstname.py: computes first name alphabetically

max.py: find maximum numeric value

name.py: echo a name

name2.py: concatenate two names

ring.py: computes area of ring with function

sign.py: computes sign of number

sort.py: sort a set of names

while.py: computes i, i^2 in a while loop

loop.py: infinite loop: careful!

for.py: Foxtrot for loop

mult.py: multiplication operation