LIST OF PRACTICALS - COMPUTER SCIENCE-CLASS 12 (2020-21)
GENERAL INSTRUCTION:
l All the program has to be executed on machine , once done, the program, input and output has to be written in the practical notebook.
l The practical Notebook should have both ruled and blank page I.e. one face of the page should be ruled and other blank (similar to physics or chemistry practical copy)
l Minimum 20 Python programs. Out of this at least 4 programs should send SQL commands to a database and retrieve the result
Program List:
FUNCTION:
1. Write a python program to compute area of a rectangle.
2. Write a python function that accepts a string and calculates the number of uppercase letter and lowercase letters:
Sample String:
Hello World
Expected Output:
No. Of Uppercase Character : 2
No of Lowercase Character: 8
3. Write a calculator function that can take two or more numbers and calculate Addition, multiplication, subtraction of these number among themselves
Example: Input: 2,3,4 Output: addition is 9, multiplication is 24 , subtraction is -5
Input: 1,2,3,4 Output: addition is 10, multiplication is 24 , subtraction is -8
4. Write a python program that accepts a hyphen-seperated sequence of words as input and prints the words in a hyphen-seperated sequence after sorting them alphabetically.
Sample Input: green-red-yellow-black-white
Expected Output: black-green-red-white-yellow
USING PYTHON LIBRARIES:
1. Create a module lengthconversion.py that stores function for various lengths conversion e.g.
a. miletokm()
b. kmtomile()
c. feettoinches()
d. inchestofeet()
2. Write a function that receives two numbers and generates a random number from that range. Using this function , the main program should be able to print three numbers randomly.
FILE HANDLING IN PYTHON:
1. Write a program that reads a text file and creates another file that is identical except that every sequence of consecutive blanks spaces is replaced by a single space.
2. Write a program to count the words ‘to’ and ‘the’ present in a text file ‘poem.txt’.
3. Write a program to count the number of upper-case alphabet present in an text file ‘article,txt’.
4. Write a program that appends the contents of one file to another. Have the program take the filename from the user.
5. Write a method in python to read the context from a text file diary.txt line by line and display the same on the screen.
6. Write a program to create a binary file with name and roll number. Search for a given roll number and display the name, if not found display appropriate message.
7. Write a program to create a binary file with roll number, name and marks. Input a roll number and update the marks.
8. Write a program to create a CSV file with roll number, name and marks. Input a roll number and update the marks
9. Create a CSV file with the following data:
Name | Math | Science | English | Hindi | SST | SUM |
John | 78 | 85 | 95 | 45 | 56 |
|
David | 65 | 58 | 82 | 57 | 89 |
|
Once created read the file and calculate the sum of all the marks for any student and update it in sum column.
DATA STRUCTURE:
1. Write a python program to implement the push operation on the stack using list.
2. Write a python program to implement the pop operation on the stack using list.
MYSQL DATABASE CONNECTION WITH PYTHON
1. Write a python program to create a a table CLUB in mysql and insert the following data in it.
Coach_id | coachName | Age | Sports |
1 | John | 35 | karate |
2 | David | 34 | karate |
3 | Tom | 34 | squash |
4 | Tim | 33 | basketball |
5 | Nathan | 36 | swimming |
6 | Peter | 36 | swimming |
7 | Tony | 39 | squash |
8 | Jack | 37 | basketball |
2. Consider the CLUB table and write a python program to display all the data from the table in a python console
Coach_id | coachName | Age | Sports |
1 | John | 35 | karate |
2 | David | 34 | karate |
3 | Tom | 34 | squash |
4 | Tim | 33 | basketball |
5 | Nathan | 36 | swimming |
6 | Peter | 36 | swimming |
7 | Tony | 39 | squash |
8 | Jack | 37 | basketball |
A. To show all information about the swimming coaches in the club.
B. To show all the Coach name in age group of 34 to 36 (Both inclusive)
4. Write a python program to get all the data from the club table and write it in a CSV file