Question 1

Write a python program that finds all numbers divisible by 7 but not multiple of 5. The range of number for searching is between 2000 and 3200 (both included). Output should be printed in a comma-separated sequence on a single line     (05 Marks)

Don't use plagiarized sources. Get Your Custom Essay on
From as low as $9/Page
Order Essay

Question 2

Write a python program that can compute the factorial of a given 2 numbers from the user. The results should be printed in a comma-separated sequence on a single line.

Input number 1: 3

Input number 2: 4

Sample Output: 6,24   (05 Marks)

Question 3

Define a python class which has at least two methods:

getString: to get a string from console input.

printString: to print the string in upper case.

You should also include functions to invoke the above-mentioned methods.  (10 Marks)

Question 4

Write a program that accepts a comma separated sequence of words as input and print the words in a comma-separated sequence after sorting them alphabetically.

Sample input: without,hello,bag,world

Sample output: bag,hello,without,world  (10 Marks)


Question 5

Write a python program that accepts a sentence and calculate the number of letters and digits in the sentence.

(10 Marks)

Question 6

Define a function that receives two integer numbers in string form and compute their sum and print it in the console.

(10 Marks)

Question 7

Write a python program that reads from a text file and print all the unique words of the file in alphabetical order.

(10 Marks)

Question 8

Write a simple banking program using python that has four options: 1. View balance 2. Make a deposit 3. Make a withdrawal 4. Quit. You must implement classes and object for this program.

(10 Marks)


Question 9

Write a program that keep track of when our friend’s birthdays are, and be able to find that information based on their name. Create a dictionary of names and birthdays. When you run your program it should ask the user to enter a name, and return the birthday of that person back to them. The interaction should look something like this:

Welcome to the birthday dictionary. We know the birthdays of:

Albert Einstein

Benjamin Franklin

Ada Lovelace

Who’s birthday do you want to look up?

User Input : Benjamin Franklin #Example

Benjamin Franklin’s birthday is 01/17/1706 #This your program should print   (10 Marks)

Question 10


Given an array of data:







Write the code for the selection sort to sort the data and draw a table showing how the data is sorted using selection sort.

Write the code for Binary search algorithm to find the value 15 from the sorted array. Draw the tree diagram showing the binary search of the list.

(20 Marks)

Question 1

Explain what happens when the following recursive function is called with the value 4 as an argument

def example(n) :

if n > o:



(05 Marks)

Question 2

  1. What are instance variables, and what role does the name “self” play in the context of a class definition?

(2.5 Marks)

  1. How is the lifetime of an object determined? What happens to an object when it dies?

(2.5 Marks)

Question 3

Define a method for the Bank class that returns the total assets in the bank (the sum of all account balances).

(05 Marks)

Question 4

Two playing cards can be compared by rank. For example, an ace is less than a 2. When c1 and c2 are cards, c1.rank < c2.rank expresses this relationship. Explain how a method could be added to the Card class to simplify this expression to c1 < c2.

Question 5

Write a python program that calculates and prints the number of minutes in a year.

(05 Marks)

Question 6

Using python, write a loop that accumulates the sum of all of the numbers in a list named data.

(2.5 Marks)

What is the purpose of the dir function and the help function?

(2.5 Marks)

Question 7

Write a function called isprime which takes a single integer argument and returns True if the integer is a prime number, and False otherwise. A prime number is a number with only two distinct divisors, 1 and itself.

Note: 1 is therefore not a prime number.

(05 Marks)

Question 8

Write a Python program that read a line of input from the user until the user enters a blank. The program should print out the total number of occurrences of each letter in the alphabet. These should be printed in alphabetical order. Your program should work like this:

> ./letters

hello world

d 1

e 1

h 1

l 3

o 2

r 1

w 1

(05 Marks)

Question 9

Why does Python code generate fewer types of syntax errors than code in other programming languages?  (05 Marks)

Question 10

Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210

(05 Marks)

Question 11

Identify the error in the following program and write the correct python source code line = raw_input(“Type a word”) print “You typed”, line line = line + “h” num = int(line) print “You typed the number “, num

(05 Marks)

Question 12

Describe two fundamental differences between terminal-based user interfaces and GUIs.

(2.5 Marks)

What roles do the parameters and the return statement play in a function definition?

(2.5 Marks)

Question 13

Write a python code to sort the given set of numbers in ascending order. You must not use any built-in functions of python.

The Homework Writings
Order NOW For A 10% Discount!
Pages (550 words)
Approximate price: -

Our Advantages

Plagiarism Free Papers

All our papers are original and written from scratch. We will email you a plagiarism report alongside your completed paper once done.

Free Revisions

All papers are submitted ahead of time. We do this to allow you time to point out any area you would need revision on, and help you for free.


A title page preceeds all your paper content. Here, you put all your personal information and this we give out for free.


Without a reference/bibliography page, any academic paper is incomplete and doesnt qualify for grading. We also offer this for free.

Originality & Security

At, we take confidentiality seriously and all your personal information is stored safely and do not share it with third parties for any reasons whatsoever. Our work is original and we send plagiarism reports alongside every paper.

24/7 Customer Support

Our agents are online 24/7. Feel free to contact us through email or talk to our live agents.

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

We work around the clock to see best customer experience.


Flexible Pricing

Our prices are pocket friendly and you can do partial payments. When that is not enough, we have a free enquiry service.


Admission help & Client-Writer Contact

When you need to elaborate something further to your writer, we provide that button.


Paper Submission

We take deadlines seriously and our papers are submitted ahead of time. We are happy to assist you in case of any adjustments needed.


Customer Feedback

Your feedback, good or bad is of great concern to us and we take it very seriously. We are, therefore, constantly adjusting our policies to ensure best customer/writer experience.