CSC 213
CSC 213
VERS
CoVENANT UNIVERSITY
CANAANLAND, KM 10, IDIROKO ROAD
P.M.B 1023, OTA, OGUN STATE, NIGERIA.
TITLE OF EXAMINATION: B.Sc.
Degree Examination
COLLEGE: College of Science and Technology
DEPARTMENT: Computer and Information Sciences SEMESTER: ALPHA
SESSION: 2021/2022
COURSECODE: CSc213 CREDIT UNIT:3
COURSE TITLE: Structured Programming TIME: 3 Hours
INSTRUCTION: Answer any FOUR(4) Questions
Question One
a
Distinguish between a Pseudocode and Flowchart 12 Marks
b. Write a Python Program that outputs the following texts 13 Marks
Python's the best!
ii. The cat said 'meow."
. Read Joshua and the Battle of Jericho' by tomorrow.
c. Consider the Code below
13.5 Marks
. Identify and Correct the Errors in the following Code
1. How many lines of names will be contained in the
philosphers.txt when the code is
executed?
d. Many companies use telephone numbers like 535-GET-FOOD so the number is easier for their
customers to remember. On a standard teleephone, the alphabetic letters are
mapped to numbers
in the following fashion:
A, B, and C-2 J, K, and L-5 T, U, andV - 8
M, N, and O - 6
D, E, and F-3 W,X, Y, and Z-9
G, H, and I-4 P,Q, R, and S -7
Write a program that asks the user to enter a 10-character telephone number in the format
XXXX. The application should display the telephone number with any alphabctic characters that
XXX-XXX
appeared in the original translated to their nuneric equivalent. For example, if the user enters 555-GET
FOOD, the application should display 555-438-3663. 19 Marks
Question Two
a. A sequence is an object that holds mulüple iems of data, stored one after the other. Define and
Mention the Characteristics of Two(2) types of sequence in Python. 2 Marks
b. Write a Python Programme that performs the following 3 Marks
i. Converts the List to a Tuple: myList =[ 'Matthew', Mark', 'Luke', "John']
. Assume the variable name references a string. Write a for loop that prints each character
in the string
111. Assume the following statement appears in a program: values
one$two$three$four' Write a statement that splits the string, creating the following
list: ["one"', 'two', 'three', ' four"']
c. Identify and Correct the Errors in the Following Code 13.5 Marks]
1 def main():
1_cities = 'Port-Harcout Abuja Markurdi Kano'
cities= cities.split(" ")
outfile = open("'cities.text', 'w')
for item in cities:
-O outfile.write(cities, ' \n')
outfile.close()
main_()
d. Quadratic equation is made from a Latin term "quadrates' which means square. It is a special
pe of equation having the form of: ax?+bx+c. Write a Pyhon program that accepts the
coefficient values ofa, b, and c and solves the vallues of x. 19 Marks
Question Three
a. Define the following Python Concepts with examples 13 Marks
Sequence Structures
. Control Structures
. Repetition Structure
1)
animal[e] = 'Z'
i) letters ABCDEFGHtikiMnoP)RSTbvwxYz
print (animal) print(letters[0:26:2])
stuff { 1 : 3, 2 : 2, 3: 1}
print(stuff[3])
For example, if a student's name is Ayanfe Adebisi, and her Matric numbcr is 20CA023345, her login
ID would be AyaAde345.
9.5 Marksl
Question Five
a Define the following concepts in Python
i. Functions
11. Dictionary 2 Marks
b. 13 Marks] What is the Output of the Following Code
myset = set("aaabbbccc'). newset= set('one two three')
i) print(newset)
print (myset)
e. Dr. Shuther teaches a Programming class and uses the following 5-point grading scale for all his
exams: He has asked you to write a program that will allow a student to enter a test score and
then display the grade for that score; such that 90 and above is A; 80 - 90 is B; 70 79 is C; 60
- 69 is D; Below 60 is F.
8 Marks