0% found this document useful (0 votes)
2 views28 pages

Practical

The document outlines a practical file for a Computer Science course for the session 2024-2025, detailing various programming tasks and exercises. It includes user-defined functions, file handling, data manipulation, and MySQL commands, aimed at enhancing programming skills in Python. Additionally, it covers Python-MySQL connectivity programs for database management and querying.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views28 pages

Practical

The document outlines a practical file for a Computer Science course for the session 2024-2025, detailing various programming tasks and exercises. It includes user-defined functions, file handling, data manipulation, and MySQL commands, aimed at enhancing programming skills in Python. Additionally, it covers Python-MySQL connectivity programs for database management and querying.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

PRACTICAL

FILE

Subject : COMPUTER SCIENCE


SESSION:2024-2025

Name : Divyansh Shukla


Class and section: XII-A
SNO. NAME OF THE PRACTICALS

Write a user defined function to find factorial of the entered number


1.
Program to check whether a number is divisible by 2 or 3 using nested
2. if

Write a program to enter two numbers and


3. print the arithmetic operations like +,-,*,/,// and %

Write a program to enter the number of


4. terms and to print the Fibonacci Series.
Write a program to enter the number and
5. print the Floyd’s triangle in decreasing order.
Write a python program to accept a string
6. and display whether it is a palindrome.
Write a program to read a string and
7. display it in reverse order. Display one
character per line, do not create a reverse
string. Just display in reverse order.
A List Num contains the following elements:
8. 3,21,5,6,14,8,14,3. Write a program to swap the content with next
value divisible by 7 so that the resultant list will look like:
3,5,21,6,8,14,3,14

Write a program to write names of three


9. students on a text named student.
Write a program to read a text file line by line and display each word
10. separated by a#
Write a function ISTOUPCOUNT() in python to read contents from a
11. text file info2.txt, to count and display the occurrence of word ‘IS’ ,
‘TO’ or ‘UP’

Write a python program which stores data in employee.csv , calculates


12. and displays the total salary remitted to its employee and display the
number of employees who are drawing salary of than 5000 per
month.

Write a program to write a student roll no, name and marks onto a
13. binary file named student.
Write a program to write a student roll no, name and percentage data
14. on a csv file named student.

Write a program to implement all basic operations of a stack, such as


15. adding element(PUSH operation),removing element(POP orientation)
and displaying the stack elements (Traversal operation) using list.

Write a program to display unique vowels present in the given word


16. using Stack.
MySQL commands
17.
MySQL Queries
18.
PYTHON MYSQL CONNECTIVITY PROGRAMMS
19.
Q1. Write a user defined function to find factorial of the entered
number.

Q2. Program to check whether a number is divisible by 2 or 3 using


nested if.
Q3. Write a program to enter two numbers and print the arithmetic
operations like +,-,*,/,// and %.
Q4. Write a program to enter the number of terms and to print the
Fibonacci Series.

Q5.Write a program to enter the number and print the Floyd’s triangle
in decreasing order.
Q6. Write a python program to accept a string and display whether it is
a palindrome

Q7. Write a program to read a string and display it in reverse order.


Display one character per line, do not create a reverse string. Just
display in reverse order.
Q8. A List Num contains the following elements: 3,21,5,6,14,8,14,3.
Write a program to swap the content with next value divisible by 5 so
that the resultant list will look like: 5,21,3,6,14,8,14,3.

Q9. Write a program to write names of three students on a text named


student.
Q10. Write a program to read a text file line by line and display each
word separated by a#.
Q11. Write a function ISTOUPCOUNT() in python to read contents from
a text file info2.txt, to count and display the occurrence of word ‘IS’
‘TO’ or ‘UP’.
Q12. Write a program to open file Student.dat and search for records
with roll numbers as 1 or2 . If found, display the records.
Q13. Write a program to write a student roll no, name and marks onto
a binary file named student.

Q14.Write a program to write a student roll no, name and percentage


Q15. Write a program to implement all basic operations of a stack,
such as adding element(PUSH operation),removing element(POP
orientation) and displaying the stack elements (Traversal operation)
using list.
Q16. Write a program to display unique vowels present in the given
word using Stack.
MySQL Command

1. Command for creating database.

2. Command for using the database.

3. Command for creating the table:

4. Command for showing the structure of table.

5.Command to show the tables present in database.


6.Command for inserting data into a table.

7.Command to view the contents of the table

8.Altering table and adding percentage column.


9.Showing the table.
QUERIES
Query1: Write a query to display grade of students
having grade A.

Query2: Write a query to display maximum


percentage from table student.

Query3.Write a query to display name and


percentage of those students, whose student_id
Is 1,4,6.
4. Write a query to delete last 3 records of the table
student.
Python-MySQL Connectivity Based Programs
Program1: Write a program to create a database
named twelth through MySQL-Python connectivity.

Program 2. Consider a table structure given below:


Tid
Tname
Tage
Tsalary
Write a program to create the above table with
MySQL-Python connectivity. (Table Name =
Teacher)
Program3: Write a program to insert data given
below in table teacher with MySQL-Python
Connectivity.
Teacher
Tid Tname Tage Tsalary
T1 Ajay Kumar 35 32000
T2 Sajeev Saxena 40 33000
T3 Rajeev Gupta 36 31000
T4 Amit Gupta 40 36000
T5 Meghna Singh 38 34000
T6 Sanjanasaxena 40 35000
Program 4: Write a python code MySQL-Python
connectivity for the following on table teacher
created in database twelth.
(a) To display details of all teachers.

(b) To display details of all those teacher who


have salary greater than 35000.

You might also like