Suggested Python Programs For Summer Assignment - I
Suggested Python Programs For Summer Assignment - I
Suggested Python Programs For Summer Assignment - I
Following programs are suggestive practice problems to develop proficiency in Python programming.
Assume that A, B, M, N are natural numbers and X, Y are float type numbers and S & W are Strings.
3. Define a function isPrime(N) to check whether N is a prime or not. If prime, the function should
return 1 otherwise 0. Using the defined function, write a program to display all prime numbers
between 1 and 100.
4. Define a function HCF(A,B) to calculate and return the HCF/GCD of the numbers A and B.
Using the defined function, write a program to check whether two user inputted M and N are
co-prime or not.
5. Define a function SumOfFactors(N) to calculate and return sum of all proper factors of N (all
factors including 1 and excluding the number N itself). Using the defined function, write a
program to check whether a number M is perfect or not.
6. Define a function SumOfFactors(N) to calculate and return sum of all proper factors of N (all
factors including 1 and excluding the number N itself). Using the defined function, write a
program to check whether 2 numbers A and B are amicable or not.
7. Define a recursive function Factorial(N) to calculate and return factorial of N. Write a program
to display factorial of the first 5 natural numbers.
8. Define a recursive function Fibonacci(N) to calculate and return N th member of the Fibonacci
number series. Write a program to display the first 20 Fibonacci numbers.
9. Define functions Pow(X,N) and Factorial(N) to calculate and return XN and N! respectively.
Using the defined function, write programs to calculate and display the sum of following series:
10. Define a function Encode(W) which encode a word (group of characters) as follows:
i) Lower case alphabets are changed into upper case alphabets and vice versa.
Characters other than alphabets remains unchanged.
ii) First character is swapped with the second character, third with the fourth character,
and so on. In case of odd number of characters, last character remains unchanged.
Write program which will read a sentence from the user and display the encrypted sentence
after encoding all words.
12. Define a function CountWord(S, W) to count and return number of occurrences of the word W
in the sentence S.
Create a List SENTENCES of 5 sentences entered by the users. Using the defined function,
count total number of occurrences of the word ‘Modern’ in the 5 sentence stored in SENTENCES.
13. Create a List SENTENCES of 5 sentences entered by the users and display the followings:
All words starts with ‘A’ or ‘a’ and size more than 4 characters
All words ends with ‘A’ or ‘a’ and size less than 4 characters
All sentences starts with alphabets ‘A’ or ‘a’
14. Write a menu based program to perform the following task on a Python List NUMBERS.
15. Write a menu based program to perform the following task on a Python List WORDS.
Write a program to check the correctness of the function with the sample values of NUMBERS
and DATA.
17. Define a function bSearch(ARR,DATA)to check whether the List of numbers ARR contains the
searched number DATA or not using Binary Search Technique. If DATA found in the List ARR,
the function should return 1 otherwise 0.
Write a program to check the correctness of the function with the sample values of NUMBERS
and DATA.
18. Write a menu (and function) based program to perform the following tasks on a Python List
STUDENTS storing name and marks of few students having the following structure and
implemented as a Stack based on LIFO operations.
19. Write a menu (and function) based program to perform the following tasks on a Python List
PERSONS storing name and age of few persons having the following structure and
implemented as a Queue based on FIFO operations.
22. Define a function FREQTable(T) which accepts a Tuple T, having few natural numbers. The
function creates a Dictionary FT to store the frequency table of individual numbers in the Tuple
T. Function finally returns the Dictionary FT.
If T=(4,2,6,2,4,2,4,2)
The function should return FT={4:3,2:4,6:1}
23. Define a function FREQTable(S) which accepts a string S, having a sentence of few words.
The function creates a Dictionary FT to store the frequency table of individual words in the
sentence STR. Function finally returns the Dictionary FT.
Note: While creating FT, ignore the space.
If STR= 'INDIANA'
The function should return FT={'I':2, 'N':2, 'D':1, 'A':2}
Write complete menu based Python - MySQL connectivity program using Table (Relation)
having suggsted Columns (Attributes) like the previous two programs,to solve the
following problems:
3. Software for a Bank # AccNo, CName, AadhaarNo, PhoneNo, BalanceAmt
File operations must include – Open a New Account, Withdrawal, Deposit
4. Inventory of a Store # PID, PName, Descriptions, SCode, MStock, CStock, Price, LDU # Last Date of Update
File operations must include – Open a New Account, Search and Display Acc. details, Withdrawal, Deposit
5. MCQ Quiz # QID, Question, OptionA, OptionB, OptionC, OptionD, Answer [A/B/C/D]
File operations must include – Add Questions, Modify Questions, Remove Questions, Play Quiz
SUGGESTIONS FOR REAL LIFE BASED GAMES USING RANDOM NUMBERS (any TWO):
Write a python program to import your own module and check all your functions for a List (and also
for a Tuple) DICE having 10 random numbers between 1 to 6 (both inclusive)