Page 1 of 1 PAPER REF.
NO
BABCOCK UNIVERSITY
SCHOOL OF COMPUTING
[QUESTION PAPER] TITLE: COMPUTER PROGRAMMING II
(Attempt ALL) (Write your code in Python language)
1) Write a named fix Time function that validates user’s input such that “26:50:12” would be alarmed
invalid for hh:mm:ss format (hours can’t be up to 26). [hh hour, mm minute, ss second]
2. Write a C++ program that will display if a student passes or fails his exam. (50% or more is a pass. If
the student passes then your program should display which letter the student has obtained.
85% or more E for excellent
75% or more but less than 85% O for Outstanding
65% or more but less than 75% G for good
Less than 65% S for satisfactory
If however the student is fails (below 50% marks) your program should display whether the student
should Resit or Redo depending on the following criteria.
33% or more Resit in exam
Less than 33% Redo course
3. A bank charges $10 per month plus the following check fees for a commercial checking account: $
10 for each fewer than 20 checks $ 8 each for 20-39 checks $ 6 each for 40-59 checks $0-5 each for
60 or more checks The bank also charge $15 if the balance for the amount falls below $400 (before
any check fees are applied). Write a program that asks a use for the beginning balance and the
numbers of check written. Compute and display the bank services fees for the month.
4. Write a program to manipulate string reference type. The program should accomplish the following:
a) Create two string variables and assign values to the strings
b) Concatenate the two string and show the output
c) Title case the string
5) Consider the following list, write a program to print the index and the corresponding element of the
list:
fruits = ['banana', 'carrot', 'mango', 'pineapple']
6) Given the following sets, define what you undersand by set difference
A = {1, 2, 3}
B = {3, 4, 5}
Then prove that A – B ≠ B – A
7) Consider the following list of your favorite food:
my_foods = ['poundo', 'amala', 'pepper soup']
Using my_foods list, create another list called pal_foods such that all the element in my_foods are
also in pal_foods list.
Then carry out the following operations in this sequential order:
i. Display the contents of my_foods and pal_foods
ii. Append ‘ewedu’ to my_foods
iii. Append ‘moimoin’ to pal_foods
iv. Display the content of my_foods and pal_foods a second time.
8) Write a python code to remove or delete all the elements called “knife” is the following list:
utensils = ["knife", "knife", "spoon", "fork", "knife", "knife", "knife", "knife"]