0% found this document useful (0 votes)
4 views4 pages

CSC 213

This document outlines the examination details for a B.Sc. degree in Computer and Information Sciences at Covenant University, including course code, title, and instructions for answering questions. It contains various programming tasks and questions related to Python, such as writing programs, correcting code errors, and explaining programming concepts. The exam covers topics like structured programming, sequences, control structures, and file handling.

Uploaded by

patgg16
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)
4 views4 pages

CSC 213

This document outlines the examination details for a B.Sc. degree in Computer and Information Sciences at Covenant University, including course code, title, and instructions for answering questions. It contains various programming tasks and questions related to Python, such as writing programs, correcting code errors, and explaining programming concepts. The exam covers topics like structured programming, sequences, control structures, and file handling.

Uploaded by

patgg16
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/ 4

oENAN UNIV

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?

1 outfile openfile( 'philosophers.txt', 'r')


=

2 outfile.write( 'John Locke \n')


3 outfile.write( 'David Hume \n ')
4 outfile.write( 'Edmund Burke\n')
for i in range(3)
name=input("Enter Philosper Name:\t")
outfile.write("name")
8 outfile.closefile ()

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

b. What is the output of the following Code? 13 Marks


animal = 'Lion'

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])

Identify and Correct the Errors in the Following Code


C.
2.5Marks
import 1ogn
def main():
3 password input( Enter your password: ')
while not login.valid_password (password)
print('That password is not valid.')
pasword = input( Enter yoOur password: )
print('That is a valid password. ')
mainO
d. Assume a file
containing series of integers is named numbers.txt and exists on the computer s
a
disk. Write a
program that reads all of the numbers stored in the file and calculates their
Maximum, Minimum, Total, and Average.
19 Marks
Question Four
a.
Fxplain the following Python Concepts with relevant Exannples
Slicing
11. Global Variable
12 Marks
b. 13 Marks] What is the Output of the Following Code
i) L [10, 20, 30, 40] for num in list([range(1, 10, 2)]):
print(L[-1], L[-2], L[-3], L[-4]) i)
print (num)
for number in
range(1, 5):
11) square= math.sqrt(number)
print(number, '\t', square)

C. Describe Three (3) Dictionary Functions with


examples (3 Marks
d. Students are assigned a portal login ID to
log into and use the University portal. As part of your
internship with the university's CSIS, you have beern asked to write the code that generates portal
login ID for students. You will use the following algorithm to generate a login ID:
1. Get the irst three characters of the student's first name. (If the first
name is less than three
characters in length, use the enire lirst name.)
11. Get the first three characters of the student's last name. (f the last name is less
than three
characters in lenglh, use the entire last name.)
111. Get he last three characters of the student's Matric Nuimber. (If the Matric
number is less han
three characters in lengh, use the enure Matric number.)
IV. Concatenate the three sets of characters to generale the portal login ID.

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)

11) print(format (987654.129, ',.5f'))


C. 13.5 Marks| Identufy and Correct the Frrors in the Following Code
1 starlist = ()
2 again ==
'y'
3 while
again.lower () 'y':
fname input( 'Enter your Favorite Bible Character :
6
star_list.append(name)
print('Do you want to add another name? ")
again input('y = yes, anything else = no: ')
8 print()
9
print( 'Here are the names you entered. ')
10 for name in star_1ist
11
print(name)
d.
Given the followingSets choir_members
TC_members
set([ 'Ade', "Amina', 'Heida', 'Segun']);
set(['Amina', 'onyeka', 'Bola', 'Ade']), write a Python progamme
that uses Python's Set Operators to perform the following operations:
Display members of the Choir.
11. Display Members of TC
1. Display members that belong to Choir and TC
V. Display members of either Choir or TC
Display members of Choir but not Tc
. Display members of TC but not Choir
VIl. Display members of Service Unit but not both 19 Marks
Question Six
a Distinguish between an Argun.ent and Paraaeter in Python's fuaction 1.5 Marks
b. Describe the File Modes in Python [1.5 Marks
C. Write a program that opens an output file with the filename things.txt, writes the name of an
animal, a fruit, and a country to the file on separate lines, then closes the file 13.5 Marks]
d. ldentify and Correct the Errors in the Following Code 3 Marks
prodnums [V475, F987, Q143, R688]
2 search = input( 'Enter a product number: ')
3 if search prod_nums
==

print('search was found in the list. ')


5 else
6 print(search, 'was not found in the list'.)

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

You might also like