


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
A computer science test from cosc 235b, held on september 29, 2008. The test covers various computer science concepts, including algorithms, variables, data types, and python programming. It includes multiple-choice questions, a programming assignment, and a problem to be solved by completing and debugging a python script.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



import string def main():
name = raw_input("Enter your full name: ")
main()
def main(): investment = input("Enter the initial investment: ") apr = input("Enter the APR: ") years = input("Enter the term of the investment (years): ")
balance = float(investment) for year in range(years): balance = balance + (balance * apr) print "End of Year %2d: $%7.2" % (year, balance)
print "After %d years, an initial investment of $%0.2f at %0.1f"+ "interest yields $%0.2f." % (years, investment, apr*100, balance) main()
Function Meaning count(s, sub) Count the number of occurrences of sub in s (^1) By program I mean everything that would have to be typed into a .py file in order for Python to successfully run this code. This includes import statements and a call to main() if a function main() is defined. Peter Piper picked a peck of pickled peppers; If Peter Piper picked a peck of pickled peppers, How many pickled peppers did Peter Piper pick?