Docsity

Python Quiz Solutions and Explanations for COSC 235B - Prof. David A. Sykes, Quizzes of Computer Science

Toggle sidebar
bg1
COSC 235B David A. Sykes
- 1 โ€“ Continued on reverse
Quiz #1
February 28, 2008
Name: Pledged:
Answer all questions. Write legibly.
1. Cross out the entries below that are not valid Python identifiers.
k Connecticut New Mexico
SevenUp Seven_Up wofford.edu
2. Show the output of the following program.
x = 7
y = 9
print x, y
3. Show the output of the following program.
print "Tricky..."
def main():
print "XOX"
print "OXO"
print "XOX"
4. Show the output of the following program.
def show():
print "XXXXX"
print "+++++"
for i in range(5):
show()
print
print "-----"
5. Write a program to display the numbers 1 through 99, each on a separate line. Use a loop.
pf2

Partial preview of the text

Download Python Quiz Solutions and Explanations for COSC 235B - Prof. David A. Sykes and more Quizzes Computer Science in PDF only on Docsity!

COSC 235B David A. Sykes

- 1 โ€“ Continued on reverse

Quiz

February 28, 2008

Name: Pledged:

Answer all questions. Write legibly.

  1. Cross out the entries below that are not valid Python identifiers.

k Connecticut New Mexico

_7_Up 7Up [email protected]

SevenUp Seven_Up wofford.edu

  1. Show the output of the following program.

x = 7 y = 9 print x, y

  1. Show the output of the following program.

print "Tricky..."

def main(): print "XOX" print "OXO" print "XOX"

  1. Show the output of the following program.

def show(): print "XXXXX"

print "+++++" for i in range(5): show() print print "-----"

  1. Write a program to display the numbers 1 through 99, each on a separate line. Use a loop.

- 2 -

  1. Explain each of the following concepts in your own words.

program

variable

assignment