Skip to document

CSC1010H Class Test 2 Past Paper Questions 2022

Course

Computer science1015 (CSC1015F)

257 Documents
Students shared 257 documents in this course
Academic year: 2022/2023
Uploaded by:
Anonymous Student
This document has been uploaded by a student, just like you, who decided to remain anonymous.
University of Cape Town

Comments

Please sign in or register to post comments.

Preview text

University of Cape Town

Department of Computer Science

Computer Science CSC1010H

Class Test 2

Past Paper Questions

Marks: 35 Approximate marks per question are shown in brackets Time: 40 minutes  The use of calculators is permitted

Surname Initials NAME:

STUDENT NO: COURSE CODE: CSC

This paper consists of 6 questions and 6 pages (including this cover page).

Mark Allocation

Question Marks Internal External Question Marks Internal External

1 5 5 5

2 5 6 8

3 8

4 4

Total Total Grand Total Final Mark

Internal Examiner: External Examiner:

Question 1. [5 marks]

Consider the following diagram which labels some of the WingIDE debugging features. Explain what purpose each of the labeled items serves.

[5]

Debug I/O Window

Breakpoint

Debug icon Step Over icon Stack Data window

Question 3. [8 marks]

Write a Python function called draw_line() which draws a line of horizontal line of characters. The draw_line() function should take two parameters, with the first being the size of the line (i. the number of characters) and the second parameter being the character with which to draw the line. This character parameter should have a default value of an asterisk (8*9). Create a main() function which tests the draw_line() function with a single size parameter value and also with a size and character parameter values.

Calling the draw_line() function with the following parameters should produce the corresponding output: draw_line(5) prints out ***** draw_line(6,9$9) prints out $$$$$$

[8]

Question 4. [4 marks]

Answer the following questions:

a) Which brackets are used to enclose parameters to a function?

[1]

b) Explain the difference between Black Box Testing and Glass Box Testing.

[2]

Indicate whether the following statements are True or False.

c) The accepted Python coding convention for module names is long descriptive names in uppercase.

[1]

Question 5. [5 marks]

Consider the following piece of code and answer the questions below:

  1. vowels = ('a','e','i','o','u')
  2. names = ['John','Obakeng','Amanda','Thando','Irvin','Portia']
  3. list1, list2, list3 = [], [], []
  4. for item in names:
  5. if item[0].lower() in vowels:
  6. list1(item)
  7. elif item[-1].lower() in vowels:
  8. list2(item)
  9. else:
  10. list3(item)
  11. print(list1)
  12. print(list2)
  13. print(list3)

a) What data type is the variable created on line 1?

[1]

b) What data type is the variable created on line 3?

[1]

c) What is the output if this code is run?

[3]

Was this document helpful?

CSC1010H Class Test 2 Past Paper Questions 2022

Course: Computer science1015 (CSC1015F)

257 Documents
Students shared 257 documents in this course
Was this document helpful?
1
University of Cape Town
Department of Computer Science
Computer Science CSC1010H
Class Test 2
Past Paper Questions
Marks: 35
Approximate marks per question are
shown in brackets
Time: 40 minutes
The use of calculators is permitted
Surname
Initials
NAME:
COURSE CODE:
CSC
This paper consists of 6 questions and 6 pages (including this cover page).
Mark Allocation
Question
Marks
Internal
External
Question
Marks
Internal
External
1
5
5
5
2
5
6
8
3
8
4
4
Total
Total
Grand Total
Final Mark
Internal Examiner:
External Examiner: