You are on page 1of 1

Practical exam: 90 minutes

1. Write a program to accept 2 integer numbers m and n, where m<n the display all
palindrom numbers in the interval [m,n]:
Example: m =150, n=250
Expect output:

2. Write a program to read through the file “words.txt” and print out the disordered
words.
Example :
File words.txt has the contents: abc cde acbb hka pal obz
Expect output:
The disordered words : acbb hka pal obz

3. Write a program to create a students class with attributes studentID, studentName,


GPA, rank and 3 functions such as __init__(self,studentID,studentname,GPA),
doRank(selft) and SaveDB(self):
a. __init__(self,studentID,studentname,GPA): initialize values for 3 attributes
studentID,studentname,GPA
b. doRank(self) : Classify students according to the following conditions
self.rank =’Excelent’ when GPA >8
self.rank =’Good’ when 8>= GPA>=6.5
self.rank = ‘Fairly Good’ when 6.5> GPA >= 5
self.rank = ‘Bad’ when GPA < 5

c. SaveDB(self) : Choose 1 of 2 tasks below


+Write information of student objects into table student(id,name,gpa,rank) in
STUDENTS.SQLITE.
+ Write information of student objects into file student.txt
Note that you need to create and save information of at least 2 student objects

You might also like