Docsity

Practice for Test 3 - Introduction to Computer Programming | CSC 1310, Exams of Computer Science

Toggle sidebar
bg1
Practice for Test 3
1. Multiple choices (exactly one correct answer). (20 pts).
Figure 1
1) What output is produced by Label 1 in Figure 1?
a) [โ€˜dโ€™, โ€˜aโ€™]
b) [โ€˜cโ€™, โ€˜bโ€™]
c) set([โ€˜aโ€™, โ€˜bโ€™, โ€˜cโ€™, โ€˜dโ€™])
d) set([โ€˜dโ€™, โ€˜aโ€™])
2) What output is produced by Label 2 in Figure 1?
a) True
b) set([โ€˜cโ€™, โ€˜bโ€™])
c) False
d) [โ€˜bโ€™, โ€˜cโ€™]
3) What output is produced by Label 3 in Figure 1?
a) [โ€˜2โ€™, โ€˜cโ€™, โ€˜dโ€™]
c) set([โ€˜2โ€™, โ€˜cโ€™, โ€˜dโ€™])
b) [โ€˜1โ€™, โ€˜cโ€™, โ€˜bโ€™]
d) set([โ€˜cโ€™, โ€˜bโ€™, โ€˜1โ€™])
4) What output is produced by Label 4 in Figure 1?
pf3
pf4
pf5

Partial preview of the text

Download Practice for Test 3 - Introduction to Computer Programming | CSC 1310 and more Exams Computer Science in PDF only on Docsity!

Practice for Test 3

1. Multiple choices (exactly one correct answer). (20 pts).

Figure 1

1) What output is produced by Label 1 in Figure 1?

a) [โ€˜dโ€™, โ€˜aโ€™]

b) [โ€˜cโ€™, โ€˜bโ€™]

c) set([โ€˜aโ€™, โ€˜bโ€™, โ€˜cโ€™, โ€˜dโ€™])

d) set([โ€˜dโ€™, โ€˜aโ€™])

2) What output is produced by Label 2 in Figure 1?

a) True

b) set([โ€˜cโ€™, โ€˜bโ€™])

c) False

d) [โ€˜bโ€™, โ€˜cโ€™]

3) What output is produced by Label 3 in Figure 1?

a) [โ€˜2โ€™, โ€˜cโ€™, โ€˜dโ€™]

c) set([โ€˜2โ€™, โ€˜cโ€™, โ€˜dโ€™])

b) [โ€˜ 1 โ€™, โ€˜cโ€™, โ€˜bโ€™]

d) set([โ€˜cโ€™, โ€˜bโ€™, โ€˜1โ€™])

4) What output is produced by Label 4 in Figure 1?

a) [โ€˜aโ€™, โ€˜cโ€™]

b) [โ€˜aโ€™, โ€˜cโ€™, โ€˜cโ€™]

c) set([โ€˜cโ€™, โ€˜aโ€™])

d) set([โ€˜bโ€™, โ€˜dโ€™])

5) What type is โ€œlineโ€ in the program?

a) list

b) changes during the execution of the program

c) depends on the data

d) string

2. We created a quiz4_module1 as following:

Now, what would be the exact printed output produced by the following segment of

code: (20 pts)

Yo Yo Yo Yo Yo

3. Read the Object Oriented code:

4. Write a Python program to read grades of a class from the text file โ€œ file4.txt โ€ as

follows (multiple lines). Convert the grades into numbers, and calculate the sum, average

score, and the maximum score of the class.(20 pts)

5. Describe the major differences of HTML and XML. Considering the following xml

file, are all the codes correct? If not, give the correct ones, and explain why? (20pts)

Tove Jani Reminder Don't forget me this weekend!

Difference: see the class notes. The correct code is:

Tove Jani

Reminder Don't forget me this weekend!

Reasons: see the class notes.