CBSERanker

Loading

List of Practical Quetions Class 12 CS- Python and SQL

List of Practical Quetions Class 12 CS- Python and SQL

Python Programming

  1. Read a text file line by line and display each word separated by a #.
  2. Read a text file and display the number of vowels/consonants/uppercase/lowercase characters in the file.
  3. Remove all the lines that contain the character ‘a’ in a file and write it to another file.
  4. Create a binary file with name and roll number. Search for a given roll number and display filename, if not found display appropriate message.
  5. Create a binary file with roll number, name and marks. Input a roll number and update the marks.
  6. Write a random number generator that generates random numbers between 1 and 6 (simulates a dice).
  7. Write a Python program to implement a stack using list.
  8. Create a CSV file by entering user-id and password, read and search the password for given user-id.
  9. Program to enter two numbers and print the arithmetic operations like +,-,*, /, // and %.
  10. Write a program to find whether an inputted number is perfect or not.
  11. Write a Program to check if the entered number is Armstrong or not.
  12. Write a Program to find factorial of the entered number.
  13. Write a Program to enter the number of terms and to print the Fibonacci Series.
  14. Write a Program to enter the string and to check if it’s palindrome or not using loop.
  15. Write a Program to search an element using linear search.
  1. Write a program to create 21 Stick Game so that computer always wins.
  • Rule of Game (Total Sticks=21):
    1. User and Computer both can pick stick one by one.
    2. Maximum stick both can pick is 4 i.e 1 to 4.
    3. Anyone with last stick will be the looser.
  1. Write a menu-driven python program to implement stack operation.
  2. Write a python program to check whether a string is a palindrome or not using stack.

Database Management

  1. Create a student table and insert data. Implement the following SQL commands on the student table:
  • ALTER table to add new attributes / modify data type / drop attribute
  • UPDATE table to modify data
  • ORDER By to display data in ascending / descending order
  • DELETE to remove tuple(s)
  • GROUP BY and find the min, max, sum, count and average.

Table Name: student

Column NameData TypeConstraints
roll_noINTPRIMARY KEY
nameVARCHAR(50)NOT NULL
marksDECIMAL(5,2)
gradeCHAR(1)
cityVARCHAR(20)
  1. Consider the following MOVIE table and write the SQL queries based on it:

MOVIE Table

Movie_IDMovieNameTypeReleaseDateProductionCostBusinessCost
M001The Kashmir FilesAction2022/01/2612450001300000
M002AttackAction2022/01/2811200001250000
M003Looop LapciaThriller2022/02/01250000300000
M004Badhai DoDrama2022/02/0472000068000
M005Shabaash MithuBiography2022/02/041000000800000
M006GehraiyaanRomance2022/02/11150000120000
  • (a) Display all information from movie.
  • (b) Display the type of movies.
  • (c) Display movieid, moviename, total_earning by showing the business done by the movies. Calculate the business done by movie using the sum of production cost and business cost.
  • (d) Display movieid, moviename and productioncost for all movies with ProductionCost greater than 150000 and less than 1000000.
  • (e) Display the movie of type action and romance.
  • (f) Display the list of movies which are going to release in February, 2022.
  1. Write following queries:
  • a) Write a query to display cube of 5.
  • b) Write a query to display the number 563.854741 rounding off to the next hundred.
  • c) Write a query to display “put” from the word “Computer”.
  • d) Write a query to display today’s date into DD.MM.YYYY format.
  • e) Write a query to display ‘DIA’ from the word “MEDIA”.
  • f) Write a query to display moviename – type from the table movie.
  • g) Write a query to display first four digits of productioncost.
  • h) Write a query to display last four digits of businessescost.
  • i) Write a query to display weekday of release dates.
  1. Suppose your school management has decided to conduct cricket matches between students of Class XI and Class XII. Students of each class are asked to join any one of the four teams – Team Titan, Team Rockers, Team Magnet and Team Hurricane. During summer vacations, various matches will be conducted between these teams. Help your sports teacher to do the following:
  • a) Create a database “Sports”.
  • b) Create a table “TEAM” with following considerations:
    • TeamID for storing an integer value between 1 to 9.
    • TeamName should be a string of length not less than 10 characters.
    • Make TeamID as the primary key.
  • c) Show the structure of the table TEAM using a SQL statement.
  • d) Insert four rows in TEAM table:
    • Row 1: (1, Tehika)
    • Row 2: (2, Toofan)
    • Row 3: (3, Aandhi)
    • Row 4: (4, Shailab)
  • e) Show the contents of the table TEAM using a DML statement.
  • f) Create another table MATCH_DETAILS and insert data as shown below.
  • MATCH_DETAILS table
MatchIDMatchDateFirstTeamIDSecondTeamIDFirstTeamScoreSecondTeamScore
M12021/12/201210793
M22021/12/2134156158
M32021/12/22138681
M42021/12/23246567
M52021/12/24145288
M62021/12/25239768
  1. Write following queries:
  • a) Display the matchid, teamid, teamscore whose scored more than 70 in first inning along with team name.
  • b) Display matchid, teamname and secondteamscore between 100 to 160.
  • c) Display matchid, teammates along with matchdates.
  • d) Display unique team names.
  • e) Display matchid and matchdate played by Anadhi and Shailab.
  1. Consider the following table and write the queries:
itemnoitemdeodeqtyunitpricestockdate
S005Ballpen102100102018/04/22
S003Gel Pen101150152018/03/18
S002Pencil10212552018/02/25
S006Eraser10120032018/01/12
S001Sharpner10321052018/06/11
S004Compass10260352018/05/10
S009A4 Papers10216052018/07/17

  • Queries:
    • a) Display all the items in the ascending order of stockdate.
    • b) Display maximum price of items for each dealer individually as per doode from stock.
    • c) Display all the items in descending orders of itemnames.
    • d) Display average price of items for each dealer individually as per doce from stock which average price is more than 5.
    • e) Display the sum of quantity for each doode.
  1. Integrate SQL with Python by importing suitable module. Create a sql table using python and accept 10 names and age. Sort in descending order of age and display.
  2. Write a MySQL connectivity program in Python to:
  • Create a database school.
  • Create a table students with the specifications – ROLLNO integer, STNAME character in MySQL and perform the following operations:
    • Insert two records in it.
    • Display the contents of the table.
  1. Perform all the operations with reference to table ‘students’ through MySQL – Python connectivity.
  2. Write a program to connect python with mysql using database connectivity and perform the following operations in database:
  • Display all the records of students in the ascending order of Name of the student.
  • Display the number of records whose name starts with D.
  • Delete the record whose ID is 3.

Leave a Reply

Your email address will not be published. Required fields are marked *