Contents
- area.py
- arith_and_assign.py
- debug_practice.orig.py
- debug_practice.py
- helloworld.py
area.py 1/5
[top][prev][next]
# Finds the area of a rectangle
# by CS111 class
width = 1.5
height = 1
# To find the area of a rectangle, you multiply the rectangle's width by the height.
area = width * height
# display the results (the area)
print("The rectangle's width is", width)
print("The rectangle's height is", height)
print("The area of the rectangle is:", area)
arith_and_assign.py 2/5
[top][prev][next]
# Demonstrates arithmetic operations and assignment statements
# by Sara Sprenkle
x = 3
y = 5
print("x =", x)
print("y =", y)
#print("x*y =", x*y)
# alternatively:
result = x * y
print("x*y =", result)
debug_practice.orig.py 3/5
[top][prev][next]
# Program to exercise our debugging skills.
# Contains one syntax error and two runtime exceptions.
# By Sara Sprenkle
x = 10
v = 7
z = x + v
a = 15
c = 8
b = b - 8
b = b - c + 1
z = c/b
print("The answer is, z)
debug_practice.py 4/5
[top][prev][next]
# Program to exercise our debugging skills.
# Contains one syntax error and two runtime exceptions.
# You can debug this program on your own.
# By Sara Sprenkle
x = 10
v = 7
z = x + v
a = 15
c = 8
b = b - 8
b = b - c + 1
z = c/b
print("The answer is, z)
helloworld.py 5/5
[top][prev][next]
# Displays a greeting
# By Sara Sprenkle
print("Hello, class!")
print("Your answer is", 4*4)
Generated by GNU Enscript 1.6.6.