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

The solutions and explanations for quiz #1 of cosc 235b, which covers python identifiers, output of print statements, and basic program structure. Students will find answers to quiz questions, as well as explanations for programming concepts such as variables and assignments.

Typology: Quizzes

Pre 2010

Uploaded on 08/19/2009

koofers-user-5w2
koofers-user-5w2 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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