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

PDF

Uploaded by

studyanyway12
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)
9 views

PDF

Uploaded by

studyanyway12
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/ 37

Allenhouse Public School

Vasundhara, Ghaziabad

Computer Science (083)


Practical File
Session: 2024 – 25
Grade: XII

Python and MySQL


Submitted By Submitted To

Jatin singh Mr. Sachin kumar


Roll No: _______ (PGT – Computer Science)
Certificate
2024-2025
Acknowledgment

I am thankful to my Cs teacher Mr. sachin kumar sir wh


helped and guided me while making this project.

Without her guidance my project would have been inco


imperfect.

The guidance and support received from all the me


contributed and who contributed and who are contribut
project, was vital for the success of the project.
INDEX
| S.No | Program
----------------------------------------------------------------------------------------------------
| 1 | Input any number from user and calculate factorial of a
number.

|2 | Input any number from user and check it is Prime no.


or not.
|3 | Write a program to find sum of elements of List
recursively.
|4 | Write a program to calculate the nth term of Fibonacci
series.

|5 | Program to search any word in given string/sentence.


|6 | Program to read and display file content line by line with
each word separated by „#‟.
|7 | Program to read the content of file and display the total
number of consonants, uppercase, vowels and lower
case characters‟.

|8 | Program to create binary file to store Roll no, Name and


Marks and update marks of entered Roll no.

|9 | Program to read the content of file line by line and write


it to another file except for the lines contains „a‟ letter
in it.
| 10 | Program to generate random number 1-6, simulating a
dice.
| 11 | write a program to accept values from user and create
a tuple.

| 12 | write a program to input name of ‘n’ countries and their


capital and currency store, it in a dictionary and display
in tabular form also search and display for a
particular country.
|13 | write a program takes in a value and spelts it backwards.
|14 | write a program to write details of students in a binary file.

|15 | write a program to count no. of lines in a text file.

|16 | write a program to create stack and perform push


(), display() and seek() function.
|17 | write a program to perform pop( function in a stack.

|18 | write a program to create queue and perform enqueue(),


display() and peek() function.

|19 | write a program to perform dequeue() function in a queue.

|20 | write a program to create a csv file and insert values


in it by using writerows function.

|21 | write a program to read from a csv file.

|22 | write a program to implement connection between


python and MySQL database.

|23 | write a program to fetch by using fetchall () function the


data from database count the total no. of rows in
a table and show all tables name present in
the database OUTPUT.

|24 | write a program program to create a table, insert values


and save it in MYSQL database.

|25 | write a program to fetch data by using fetchmany()


function.
|26 | MySQL Program Question 1.
|27 | MySQL Program Question 2.
Program : 1

Input any number from user and calculate factorial of a number

OUTPUT
Program: 2

Input any number from user and check it is Prime no. or not

#Program to input any number from user


#Check it is Prime number of not

OUTPUT
Program: 3

Write a program to find sum of elements of List recursively

#Program to find sum of elements of list recursively

OUTPUT
Enter how many number :6
program: 4

Write a program to calculate the nth term of Fibonacci series

OUTPUT
Enter the 'n' term to find in fibonacci :10
Program: 5

Program to search any word in given string/sentence

OUTPUT

Enter any sentence :my computer your computer our computer everyones computer
Program:6

Program to read and display file content line by line with each
word separated by „#‟

NOTE : if the original content of file is:


India is my country I love python Python learning is fun

OUTPUT

India#is ntry#
Program:7

Program to read the content of file and display the total number
of consonants, uppercase, vowels and lower case characters‟

NOTE : if the original content of file is:


India is my country I love python Python learning is fun

OUTPUT
1
Program:8

Program to create binary file to store Rollno,Name and Marks


and update marks of entered Rollno

#Program to create a binary file to store Rollno and name


#Search for Rollno and display record if found
#otherwise "Roll no. not found"
OUTPUT

Page : 11
Program:9

Program to read the content of file line by line and write it to


another file except for the lines contains „a‟ letter in it.

#Program to read line from file and write it to another line


#Except for those line which contains letter 'a'

OUTPUT

NOTE: After copy content of file2copy.txt


one two three four
five six seven
eight nine ten
bye!

Page : 12
Program:10

Program to generate random number 1-6, simulating a dice

OUTPUT

Page : 15
Program:11

write a program to accept values from user and create a tuple.

OUTPUT
Program:12
write a program to input name of ‘n’ countries and their capital and
currency store, it in a dictionary and display in tabular form also search
and display for a particular country.

OUTPUT
Program:13

write a program takes in a value and spelts it backwards

OUTPUT

Page : 15
Program:14

write a program to write details of students in a binary file.

OUTPUT
Program:15

write a program to count no. of lines in a text file.

OUTPUT
Program:16

write a program to create stack and perform push(, display( and speek(
function.

OUTPUT
Program:17

write a program to perform pop( function in a stack.

OUTPUT
Program:18

write a program to create queue and perform enqueue(), display() and peek()
function.

OUTPUT
Program:19

write a program to perform dequeue() function in a queue.

OUTPUT
Program:20

write a program to create a csv file and insert values in it by using writerows
function.

OUTPUT
Program:21

write a program to read from a csv file.

OUTPUT
Program:22

write a program to implement connection between python and MySQL database

OUTPUT
Program:23

write a program to fetch by using fetchall() function the data from database count the
total no. of rows in a table and show all tables name present in the database OUTPUT

OUTPUT

Page : 15
Program:24

write a program program to create a table, insert values and save it in MYSQL
database.

OUTPUT-

Page : 15
Program:25

write a program to fetch data by using fetchmany() function

OUTPUT

Page : 15
MY SQL QUERIES
-Consider the following MOVIE table and write the SQL queries based on it

a) select * from movie;


b) select distinct from a movie;

c) select movieid, moviename, productioncost + businesscost


"total earning" from movie;

d) select movie_id,moviename, productioncost from movie


where producst is >150000 and <1000000;

e) select moviename from movie where type ='action' or type='romance';


f) select moviename from movie where month(releasedate)=2;
Answers-
a) create database sports;

b) Creating table with the given specification


create table team
(teamid int(1),
teamname varchar(10), primary key(teamid));

c) desc team;

You might also like