0% found this document useful (0 votes)
18 views6 pages

Network Programming II Practice Test 3

This document is a practice test for the Network Programming II subject at Walter Sisulu University, aimed at Diploma in ICT in Communication Networks students. It consists of multiple-choice questions, true or false statements, and short answer questions, covering various programming concepts and Python functions. The test is designed to assess students' understanding of network programming principles and Python coding skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Network Programming II Practice Test 3

This document is a practice test for the Network Programming II subject at Walter Sisulu University, aimed at Diploma in ICT in Communication Networks students. It consists of multiple-choice questions, true or false statements, and short answer questions, covering various programming concepts and Python functions. The test is designed to assess students' understanding of network programming principles and Python coding skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

WALTER SISULU UNIVERSITY

DEGREE AND DIPLOMA EXAMINATIONS


PRACTICE TEST 3

SUBJECT : NETWORK PROGRAMMING II

SUBJECT CODE : NTP26W0

QUALIFICATION : DIPLOMA IN ICT IN COMMUNICATION NETWORKS

EXAMINER/S : MR JA OKUTHE

MODERATOR : DR O OKI

INSTRUCTIONS
• Answer ALL questions.

REQUIREMENTS

ANNEXURES/ADDENDA : NONE

DURATION : 1 Hour 30 Minutes

MARKS : 50

NUMBER OF PAGES : 5 pages (including cover page)

Pa ge 1|6
SECTION A (MULTIPLE CHOICE) [10 MARKS]

1.1 What will be the output of the following code?

a. [10, 20, 30, 40]


b. [20, 30, 40]
c. [20, 30, 40, 50]
d. [30, 40, 50]
1.2 Which of the following statements best describes arguments with respect to functions?
a. They exist only inside functions in which they have been defined.
b. They exist outside functions and are carriers of values passed to functions.
c. They are special key words used with user defined functions.
d. They represent variables associated with inbuilt functions.
1.3 What will be the output of the following code?

a. 1
b. 3
c. 4
d. 5
1.4 Which of the following statements best describes immutable data?
a. They cannot be modified at run time.
b. They can be freely updated at any time.
c. They move easily between a function and the main program.
d. They are variables linked to inbuilt functions.
1.5 What will be the output of the following code?

a. (10, 5, 3)
b. (10, 5)
c. (5, 3, 7)
d. (5, 3)
1.6 Which of the following statements best describes a Python package?
a. A single file that defines functions, classes, and variables and may also include
runnable code.
b. Contains collections of functions and global variables organized in a directory
hierarchy.
c. Mutable data structures that allow you to store key-value pairs.
d. A data structure representing an immutable, ordered collection of elements.

Pa ge 2|6
1.7 What will be the output when the following code is executed?

a. dave
b. 226578543
c. 334125798
d. 555123454
1.8 What will be the output from the following code?

a. 4
b. 5
c. 6
d. 7
1.9 Which of the following statements best describes a ValueError exception?
a. Occurs when dealing with variables that are inappropriately used in some context.
b. Shows up when a data type cannot be accepted in the current context.
c. Arises when trying to activate a method which does not exist in an item under
consideration.
d. Raised when the control reaches a line of code which violates Python’s grammar
1.10 Refer to the exhibit.

The entity win is most likely a _________.


a. function
b. module
c. package
d. Python keyword

Pa ge 3|6
SECTION B (TRUE OR FALSE) [5 MARKS]
2.1 A variable created outside any function is visible inside the function.
2.2 A dictionary is a mutable data type.
2.3 A function does not belong to any data.
2.4 Even the most careful programmer is not able to avoid minor or major defects in program
development.
2.5 A module is is a file containing Python definitions and statements.

SECTION C (SHORT ANSWER QUESTIONS) [35 MARKS]


3.1 Python functions originate from four possible sources. These are built-in, preinstalled,
user defined and methods.
a) Match the given description of Python function to its corresponding name. List only
the question number and matching option, e.g., 3.1 (a) Preinstalled. (4)
Criterion for expressing correctness of Name
a program
a) Written and placed inside the code by the Built-in
programmer Preinstalled
b) Connected with classes in the object-oriented User
paradigm defined.
c) Are an integral part of Python such as print() Methods
d) Included in modules and are less often used

b) Consider the following Python code.

i. What will be the output when this code is executed? (2)


ii. Rewrite this code using the while loop. (4)

Pa ge 4|6
3.2 Consider the following Python code.

a) List the output expected when the code is executed. (2)


b) Rewrite the code to remove the cow:moo key value pair and display the contents of
the dictionary before and after the removal of this key value pair. (4)

3.3 A function's power is revealed when it can accept data provided by the user. A Python
program that uses functions includes parameters and arguments as variables.

a) List any two differences between parameters and arguments. (2)


b) Consider the following Python code.

i. Identify any two parameters used in the program. (2)


ii. Rewrite the function using the return instruction (4)

3.4 Modules and packages are used in Python to enhance the structure of large and complex
programs.
a) List and discuss any two differences between modules and packages. (2)
b) Consider the following Python code.

i. Does the entity pi represent a module of a function? (1)


2
ii. Given that the area of a circle is determined by the formula A=πr , rewrite the
program to compute the area of the circle. (2)

Pa ge 5|6
3.5 Python slice() function returns a slice object in a sequence. The programmer can specify
where to start the slicing, and where to end.

a) Discuss the purpose of using the slice() function in a program. (2)


b) Consider the code below.

i. List the output expected when the code is executed. (2)


ii. Using either positive or negative indices, rewrite Line 3 of the code so that
the following new list is displayed [1, 6, 3]. (2)

=========================== THE END ===========================

Pa ge 6|6

You might also like