You are on page 1of 6

Teacher Initial:

Daffodil International University AS


Summer 2021
Department of Computer Science and Engineering
Midterm Open Book Examination Answer Script
Full Marks: 25 Allowed, Time: 2:30 hrs.
Date: Sunday 4, July 2021

General Information (must be filled by the student)


COURSE CODE: CSE233 SECTION: I PROGRAM: DAY EVEN

STUDENT ID: 201-15-13804 TIME STARTED: 9:00 AM TIME ENDED: 11:30 AM

[Student must either TYPE or HAND WRITE the answers in this template; In case needed just
write your detail on the paper using hand]

Answer to the question number: 1

a)ans:

This python program using the for loop to print vowels in a string. We will take a user-
defined function to check and print if a string contains vowels.

Right code is:


dele = []
newstr = []
string = input("Enter any string: ")
ele = ('a', 'e', 'i', 'o', 'u')
for x in string. lower():
if x in ele:
dele.append(x)
else:
newstr.append(x)
print(f'New string is: {newstr} from {string}')
print(f'Deleted are: {dele}')

Output is:
Enter any string: oop
New string is: ['p'] from oop
Deleted are: ['o', 'o']

** Plagiarism will be checked while you submit your response. You are advised to be honest during
the open book exam.
Student ID: 201-15-13804

b)ans:

My ID is 201-15-13804.
My id last digit 4, now index will be 4

Code is:
sectionC= ["a","b","c","d","e"]
print(sectionC)
sectionD= ["f","g","h","i","j"]
print(sectionD)
sectionE= ["k","l","m","n","o"]
print(sectionE)
sectionG= ["p","q","r","s","t"]
print(sectionG)

sectionCE = sectionC + sectionE


print(sectionCE)
sectionCE.pop()
print(sectionCE)
sectionDG = sectionD + sectionG
print(sectionDG)
sectionDG.pop()
print(sectionDG)
sectionCE.insert(9, "e")#inserting index 4 in last operation
print(sectionCE)
sectionDG.insert(9, "j")#inserting index 4 in last operation
print(sectionDG)

Output is:

['a', 'b', 'c', 'd', 'e']


['f', 'g', 'h', 'i', 'j']
['k', 'l', 'm', 'n', 'o']
['p', 'q', 'r', 's', 't']
['a', 'b', 'c', 'd', 'e', 'k', 'l', 'm', 'n', 'o']
['a', 'b', 'c', 'd', 'e', 'k', 'l', 'm', 'n']
['f', 'g', 'h', 'i', 'j', 'p', 'q', 'r', 's', 't']
['f', 'g', 'h', 'i', 'j', 'p', 'q', 'r', 's']
['a', 'b', 'c', 'd', 'e', 'k', 'l', 'm', 'n', 'e']
['f', 'g', 'h', 'i', 'j', 'p', 'q', 'r', 's', 'j']

** Plagiarism will be checked while you submit your response. You are advised to be honest during
the open book exam.
Student ID: 201-15-13804

Answer to the question number: 2

a)ans:
Code is:
given = (input())
filter = given[1:len(given) - 1]
filter = filter.split(',')

filter = str(filter)

filter = filter.lower()
vowel = "aeiou"
number_of_char = 8
number_of_vowel = 8
for i in filter:
if 'a' <= i <= 'z':
number_of_char = number_of_char + 1
for v in vowel:
if v == i:
number_of_vowel = number_of_vowel + 1
elif '0' <= i <= '9':
number_of_char = number_of_char + 1
print("Number of Character:", number_of_char)
print("Number of Vowel:", number_of_vowel)

Output is:
Mehedi, Rangpur, 201-15-13804, DIU
Number of Character: 32
Number of Vowel: 14

** Plagiarism will be checked while you submit your response. You are advised to be honest during
the open book exam.
Student ID: 201-15-13804

b)ans:

Code is:

for BangYooHoo in range(51):


if BangYooHoo% 3 == 0 and BangYooHoo% 5 == 0:
print("BangYooHoo")
continue
elif BangYooHoo % 3 == 0:
print("bang")
continue
elif BangYooHoo % 5 == 0:
print("YooHoo")
continue
print(BangYooHoo)

Output is:

BangYooHoo
1
2
bang
4
YooHoo
bang
7
8
bang
YooHoo
11
bang
13
14
BangYooHoo
16
17
bang
19
YooHoo
bang
22
23
bang
YooHoo
** Plagiarism will be checked while you submit your response. You are advised to be honest during
the open book exam.
Student ID: 201-15-13804

26
bang
28
29
BangYooHoo
31
32
bang
34
YooHoo
bang
37
38
bang
YooHoo
41
bang
43
44
BangYooHoo
46
47
bang
49
YooHoo

** Plagiarism will be checked while you submit your response. You are advised to be honest during
the open book exam.
Student ID: 201-15-13804

c)ans:

Code is:

print("...............................")
print("Hall management system")
print("...............................")
room_avi = [501, 502, 503,504]
room_no = ["501A", "501B", "501C", "501D","502A", "502B", "502C", "502D",
"503A", "503B", "503C", "503D","504A", "504B", "504C", "504D"]
room = input()
if room not in room_no:
print("Room is unavilable for you")
sits = {"501":4, "502":4, "503":2, "504":4, }

Output is:
...............................
Hall management system
...............................
501
Room is unavilable for you

** Plagiarism will be checked while you submit your response. You are advised to be honest during
the open book exam.

You might also like