


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Python programming assignments from cosc 235b course by david a. Sykes. It includes various tasks such as calculating the slope of a line, running python programs, and displaying a horizontal bar chart based on data from a file.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



x = 100 m = 0. b = 10 y = m * x + b print "y =", y
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" print "1)", len(alphabet) print "2)", alphabet[2] print "3)", ord('C') - ord('A') print "4)", alphabet[2:6] print "5)", alphabet[:13] + alphabet[13:] print "6)", alphabet[0:4].lower()
print "->", for ch in "ABCDEF": print ch, print
def foo(amt): amtLeft = amt for x in [ 25, 10, 5, 1]: n = amtLeft / x print x, ':', n amtLeft = amtLeft % x
foo(72)
def bar(n): "Do something" s = 0 for i in range(1, n+1): s = s + i return s
print "bar(3) =", bar(3)
2 1
2 1 x x
y y slope −