You are on page 1of 9

Guidelines for practical file

1. Make first page as title page


2. Second page as index
3. Keep font size of entire file same, Program statement
as bold and font style same for all the programs
4. Start new program on next page
5. Crop output screen as necessary
6. Program sequence - Total no of questions -21
You have to define functions in at least 10 questions
File handling - 5 ( which includes strings, lists, dictionary and
tuples with text files, binary files and csv files)
Recursion - 2
Binary Search-1
Stack -1
Queue -1
Sorting -2
Loops and control statements -3
Python Interface - 2
SQL - 4

File Handling:
1. Program to read a file named “article.txt”, count and print total
alphabets in the file.
2. Program to read a file named “article.txt”, count and print various data.
3. Program to read a file named “story.txt”, count and print total words
starting with “a” or “A” in the file.
4. Program to read a file named “story.txt”, count and print total lines
starting with vowels in the file.
5. Function to remove all the lines that contain the character `a' in a file
and write it to another file.
6. Write a python program to read a file named “article.txt”,
count and print the following:
(i). length of the file(total characters in file)
(ii).total alphabets
(iii). total upper case alphabets
(iv). total lower case alphabets
(v). total digits
(vi). total spaces
(vii). total special characters
(viii). total no of vowels

7. To get r.no. , names and marks of the students of a class and


store these details in a file called "Marks.csv".

Loops and Control statements:


1. Menu-driven program in python which takes an integer number as input and as per
user choice checks whether the number is a prime number or a palindromic
number.
2. Random number generator using functions that generates random numbers
between 1 and 6 (simulates a dice).
3. Program to remove duplicate words from a string.
4. Program to take input for a number check if the entered number is Armstrong or
not.
5. Write a program to create a guessing game in Python.

6. Write a menu-driven program in python language which takes an


integer number as input and as per user choice checks whether the
number is a prime number(having only 2 factors) or a palindromic
number (reverse of the number is equal to the original number).
7. Write a python program to enter a string and a substring. It should
then display the number of occurrences of the given substring in the
line.
8. Program to print whether a given character is an uppercase or a
lowercase character or a digit or any other character.
9. Write a python program to replace one string with the other string.
10. Write python program to enter a string and then enter a character and
check the frequency of that character in that string.
11. Write a python program that receives the index and returns the
corresponding value.
12. Write a python program that inputs two tuples and creates a third that
contains all elements of the first followed by all elements of the second
13. WAP that returns the largest even number in the list of integers. If
there is no even number in input, print ”No even number”.
14. WAP that prints the sum of the even indexed elements of L, minus the
sum of the odd-indexed elements of L.
15. WAP to find the median and mode from a given list.
16. WAP that users a dictionary that contains ten usernames and
password. The program should ask the user to enter their username
and passwords. If user name is not in the dictionary, the program
should indicate that the person is not a valid user of the system. IF the
user name is in the dictionary, but the user does not enter the right
password, the program should say that the password is invalid. If the
password is correct, then the program should tell the user that they
are now logged into the system.
17. Create a nested dictionary that stores the marks details along with
student names and then prints the output.
18. WAP to perform sorting on a given list of strings, on the basis of just
the first letter of the strings. Ignore all other letters for sorting
purposes.
19. Create a python program to make the following games: (any one)
Rolling the dice
Python Hangman Game
Tic-tac-toe

Recursion:
1. Program to take input for a number and print its factorial using
recursion
2. Program to Display Fibonacci Sequence Using Recursion
3. Write a python script to take input for a number and print its
factorial using recursion?

Python-Mysql Interface:
1. Function to create a table in MySQL using python and MySQL interface.
2. Function to insert a record in table ‘Students’ using python and MySQL
interface.
3. Function to search a record stored in a table using python and MySQL
interface.
4. Function to display a record stored in a MySQL table according to the
user requirement (using python and MySQL interface).

Mysql:
1. Query to find the number, dealer, and price of the most expensive
article
2. Query to find the highest price per article.
3. For each article, find the dealer or dealers with the most expensive
price.
4. Query to calculate the number of days per month a user has visited a
Web page

Stacks:
1. Program to maintain book details like book code, book title and price
using stacks data structures (implement push(), pop() and traverse()
functions).

Queues:
1. Program to maintain employee details like empno,name and salary
using Queues data structure (implement insert(), delete() and traverse()
functions).

Binary Search:
1. Write a function to implement binary search to input a list and an
element, and return the index of the element in that list.
Sorting:

1. Function to implement insertion sort.


2. Function to implement bubble sort
PRACTICAL
FILE

Submitted By:
Name-___________
Class - ______XII-F
Roll No.-__________
Teacher’s
S.No. Title of the Program
Sign
1. Write a program to check if a string is palindrome or not.

2. Write a recursive code to find the sum of all elements of a


list.

3. Write a recursive code to compute the nth Fibonacci number.

4. Write a random number generator using functions that


generates random numbers between 1 and 6 (simulates a
dice).

5. Write a recursive code to compute factorial of a number.

6. Write a program for binary search.

7. Write a code for insertion sort.

8. Write a program to count the number of vowels in a string.

9. Write a program to print all duplicates from a list of


integers.

10. Write a program that returns the largest even number in the
list of integers.

11. Write python program to enter a string and then enter a


character and check the frequency of that character in that
string.

12. Write a program to perform sorting on a given list of strings,


on the basis of just the first letter of the strings. Ignore all
other letters for sorting purposes.
13. Write a program to display elements on main diagonal of 2D
list object which is passed as parameter.

14. Create a nested dictionary that stores the marks details along
with student names and then prints the
output.

15. Write a program to implement addition of matrices using


nested lists.

16. From a data file, named story.txt, display the words starting
from “A”.

17. From the file data.txt, display the words which do not have
vowel.

18. From a file mydata.txt find out number of uppercase


characters, lower case characters and digits.

19.

20.

21.

22.

23.

24.

25.
Sample Program (Formatting)

Q.1 Write a program to check if a string is palindrome or


not.

Input Code

def isPalindrome(str):

if str is None or not str:


return False

i = 0
j = len(str) - 1
while i < j:
if str[i] != str[j]:
return False
i = i + 1
j = j - 1

return True

if __name__ == '__main__':

str = "XYBYBYX"

if isPalindrome(str):
print("The String is Palindrome")
else:
print("The string is Not Palindrome")
Output Screen

You might also like