0% found this document useful (0 votes)
2 views

PYTHON PRACTICAL FILE

The document outlines a series of Python programming practicals, including tasks such as checking for palindromes, counting character statistics, and manipulating lists and dictionaries. It also includes file handling exercises involving reading from and writing to text and binary files, as well as database connectivity tasks. Each practical is numbered and provides a brief description of the expected functionality.

Uploaded by

Its me
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

PYTHON PRACTICAL FILE

The document outlines a series of Python programming practicals, including tasks such as checking for palindromes, counting character statistics, and manipulating lists and dictionaries. It also includes file handling exercises involving reading from and writing to text and binary files, as well as database connectivity tasks. Each practical is numbered and provides a brief description of the expected functionality.

Uploaded by

Its me
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

PYTHON PROGRAMMING FILE

SUBMITTED TO SUBMITTED BY

LIST OF PRACTICALS:
1
S.NO PROGRAM T. Sign
.

1 Write a program to show if the entered string is a palindrome or not.

2 Write a program to show statistics of characters in the given line (to count the
number of alphabets, digits, uppercase, lowercase, spaces and other
characters).

3 Write a program to display frequencies of all the elements of a list.

4 Write a program to display those strings which are starting with ‘A’ from the
given list.

5 Write a program to find and display the sum of all the values which are
ending with 3 from a list.

6 Write a program to delete the duplicate element from the list

7 Write a program to swap the content with next value, if it is divisible by 7

8 Write a program to accept values from a user and create a tuple.

9 Write a program to input the names of ‘n’ countries and their capital store in
a dictionary.

2
Ex d = {“India”:”New Delhi” ,……}

10 Write a program to show GCD of two positive numbers.

11 Write a function in python to read lines from text file poem.txt and display
words which are less than four character

12 Write a program to show and count the number of words in a text file
‘DATA.TXT’ which is starting with the words' The', ‘the’.

13 Write a program to read data from a text file DATA.TXT, and display each
word with a number of vowels and consonants.

14 Write a program to read data from a text file DATA.TXT, and display words
which have maximum/minimum characters.

15 Consider a binary file “Emp.dat '' containing details such as empno:


ename:salary(separator‘:’).Write a python function to display details of those
employees who are earning between 20000 and 40000.

16 Write a program to insert list data in a CSV File and print it.

17 Following is the structure of each record in a data file named”


PRODUCT.DAT”.

{"prod_code":value, "prod_desc":value, "stock":value}

The values for prod_code and prod_desc are strings, and the value for stock is

3
an integer.

Write a program in PYTHON to update the file with a new value of stock.
The stock and the product_code, whose stock is to be updated, are to be input
during the execution of the function.

18 Assuming the tuple Vehicle as follows:

( vehicletype, no_of_wheels)

Where vehicletype is a string and no_of_wheels is an integer.

Write a program to read all the records present in an already existing binary
file SPEED.DAT and display them on the screen, also count the number of
records present in the file.

19 Write a MENU DRIVEN program to show push and pop operation using
stack.

20 Write a Python program to create a dictionary from a string. .

Note: Track the count of the letters from the string.

Sample string : 'computeerr'

Expected output: {c:1 ,o:1,m:1 , p:1, u,:1 ,t:1 , e:2 ,r:2}

21 Write a Python program to combine two dictionary adding values for


common keys. .

d1 = {'a': 100, 'b': 200, 'c':300}

d2 = {'a': 300, 'b': 200, 'd':400}

Sample output: Counter({'a': 400, 'b': 400, 'd': 400, 'c': 300})

22 Write a Program in Python to sort a tuple of tuples by 2nd item

tuple1 = (('a', 23),('b', 37),('c', 11), ('d',29))

4
Expected output:

(('c', 11), ('a', 23), ('d', 29), ('b', 37))

23 Write a python program to connect to your database server and print its
version

24 Write a python program with Mysql connectivity based on above table:

Hospital
Hospital_id Hospital_Name Bad Count

1 Apollo Hospital 200

2 Yashoda Hospital 400

3 Max Hospital 1000

4 Life Hospital 1500

Doctor
Doctor_id Doctor_Name Hospital_id Joining_Date Speciality Salary Exp
.

101 Dr. Anuj 1 2005-12-05 Oncologist 250000 Null

102 Dr. Amit 2 2012-11-22 Radiologist 260000 Null

103 Dr. Rajni 2 2013-11-12 Pediatric 270000 Null

104 Dr. Jyoti 4 2008-07-03 Oncologist 210000 Null

i Fetch Hospital and Doctor Information using hospital Id and doctor Id

ii Get the list Of doctors as per the given specialty and salary

iii Get a list of doctors from a given hospital

5
iv Update doctor experience in years

v add record in Doctor table .

1)Write a program to show if the entered string is a palindrome or not.

Output

2)Write a program to show statistics of characters in the given line (to count the number of
alphabets, digits, uppercase, lowercase, spaces and other characters).
6
3)Write a program to display frequencies of all the elements of a list.

4)Write a program to display those strings which are starting with ‘A’ from the given list.

Output

5)Write a program to find and display the sum of all the values which are ending with 3 from a
list.

Output

6)Write a program to delete the duplicate element from the list


7
Output

7)Write a program to swap the content with next value, if it is divisible by 7

output

8)Write a program to accept values from a user and create a tuple.

8
Output

9)Write a program to input the names of ‘n’ countries and their capital store in a dictionary.

Ex d = {“India”:”New Delhi” ,……}

Output

9
10

10)Write a program to show GCD of two positive numbers.

output

11)Write a function in python to read lines from text file poem.txt and display words which are
less than four character

10
13)Write a program to read data from a text file DATA.TXT, and display each word with a
number of vowels and consonants.

Output

11
14)Write a program to read data from a text file DATA.TXT, and display words which have
maximum/minimum characters.

12
Output

15)Consider a binary file “Emp.dat '' containing details such as empno:


ename:salary(separator‘:’).Write a python function to display details of those employees who
are earning between 20000 and 40000.

16)Write a program to insert list data in a CSV File and print it.

Output

13
17)Following is the structure of each record in a data file named” PRODUCT.DAT”.

{"prod_code":value, "prod_desc":value, "stock":value}

The values for prod_code and prod_desc are strings, and the value for stock is an integer.

Write a program in PYTHON to update the file with a new value of stock. The stock and the
product_code, whose stock is to be updated, are to be input during the execution of the function.

14
15

You might also like