Practical 12.docx Flipbook PDF

Practical 12.docx
Author:  J

94 downloads 231 Views 491KB Size

Story Transcript

PRACTICAL FILE – CLASS XII MINIMUM 20 PROGRAMS (MINIMUM 4 SHOULD BE MYSQL PYTHON CONNECTIVITY) Note : GIVE SAMPLE OUTPUT FOR CLARITY FUNCTION/RANDOM BASED CONCEPT Write a python program having user defined functions to do the following: a. prime(n) - to generate a random number 'n' between 10 and 20(both inclusive) to display whether n is prime or not. b. fib(m) - to generate a random number 'n' between 5 and 10 and to print Fibonacci series less than or equal to m. c. palin(s) - to accept a string from user and to display whether it is a palindrome or not. d. palin(s) - use the same function to check whether a natural number accepted from user is palindrome or not. LIST/DICTIONARY/ RANDOM/STATISTICS BASED CONCEPT (Any list based operations as user defined functions like swapping / searching(linear/binary) / sorting(bubble/selection)/sum/ product/ count/ creating new list from an existing list, dictionary based operations) Write a Python program to accept a list named d and Invoke shiftleft(d) to shift elements of list 'd' to one position left. Invoke crlist(d) to Create two lists 'b' and ‘c’ , b – one without duplicates and 'c' -one with duplicates (without repetition) Invoke stat(d) to Display mean, median and mode of list 'd' Invoke create() to create and display list 'a' having 10 random numbers which are multiples of 5 between 50 and 75 (both inclusive). Define each of the above user defined functions. Sample Output: Enter a list:[12,3,4,3,12,5,7,12,12] Before Shifting : [12, 3, 4, 3, 12, 5, 7, 12, 12] After shifting : [3, 4, 3, 12, 5, 7, 12, 12, 12] List without duplicates: [12, 3, 4, 5, 7] List of duplicates(without repetition) : [3, 12] Mean = 7.78 Median= 7 Mode= 12 Random list: [65, 60, 60, 70, 55, 65, 75, 50, 65, 50]

DICTIONARY Write a menu driven program having menu options add()- to add book code, name and price of books to a dictionary dispall() - to display details of all books remv() - to remove details of a book for a given book code editprice() - to change price of a book for a given book code STACK/QUEUEWrite a program to implement stack as a list using user defined functions. Write a program to implement queue as a list using user defined functions. (Its better to teach as user defined as functions since for theory exam they usually ask to define as function) BINARY FILES,TEXT FILES,CSV FILES The binary files can be done with list, tuples or dictionary ( tuples restrict it to create and display and search(immutable))- editing/deleting possible in tuples (but then we use list/dict since we can edit directly - mutable). BINARY FILE- EACH RECORD AS A LIST Write a menu driven program having menu options add() - to add records to the binary file "empns.dat" - Each record is a list having employee id ,name and salary displist() - to display all records dispsal() - to display details of employees having salary > 20000 dellist() - to delete details of an employee for a given employee id editlist() - to modify salary of an employee for a given employee id. BINARY FILE - SINGLE NESTED LIST Write a menu driven program having user defined functions create() - to create a SINGLE NESTED list containing roll number, name and marks stored in a binary file result.dat append() - to add records display()- to display all records disp80() - to display name of students who have scored above 80 rmv() - to remove details of student of a given roll number edit() - to edit marks of student of a given roll number BINARY FILE – SINGLE DICTIONARY A binary file products.dat contains details of products of a shop stored as a single dictionary – where key is the product code and values are item name and price as in example – {‘G1’:[ ‘INK’, 120], ‘B7‘:[ 'SOAP’,50], A7’:[‘OIL’,60],’NC4’:[‘SOAP’: 75]}.

Write user defined function a. To create file b. To append records c. To display details of all products d. To display product code and price where item name is OIL e. To remove item details of a given product code. f. To modify price of a given product code. BINARY FILE – EACH RECORD AS A DICTIONARY A binary file flight.dat contains details of flight where flight code is the key and the values are destination and fare. Write user defined function a. To create file b. To append records c. To display details of all flights d. To display details of all flights to a given destination e. To remove details of a given flight code. f. To modify fare of a given flight code. BINARY FILES – DICTIONARY – EACH RECORD AS A DICTIONARY – EACH RECORD HAS MULTIPLE KEYS AND VALUES A binary file stud.dat contains multiple records each store as dictionary with sample data {‘Rno’:1,’Name’:’ Anju’ , ‘Marks’: 70 } as 1st record, {‘Rno’:2,’Name’:’ Sachin’, ‘Marks’:83} as 2nd record and so on. Write separate user defined functions 1. To append details, 2. To display name and marks of a given roll number, 3. To display name of students having marks greater than 80, 4. To remove details of a given roll number 5. To modify marks of roll number 34. CSV FILES Write a menu driven program having options : create() - to create a CSV file item.csv to store Item Code, Item Name and Price dispall() - to display details of all items disp70() - to display name and count of items having price > 70. dispsoap() - to display item details if item name contains "soap". Also display the count of the same. edit() - to edit price of a given item code remv() – to remove details of a given item code.

TEXT FILES Write a program having user defined functions to do the following 1.To create a file abc.txt to store a string accepted from user using a function crt() 2.To create a new file 'def.txt' to store words not having 'e' and 'E' from the file abc.txt using a function crtdef() 3.To replace all ‘this’ with ‘that’ of the text file abc.txt using a function thisthat() Write a program having user defined functions to do the following– a. To store name, age and runs of members of a cricket team in a text file score.txt, where each team member’s detail is stored in the format name#age#runs. b. To display the name of players who have scored 50 runs of more from the above file score.txt. Also display the count of same. c. To display details of players whose name ends with 's' from score.txt Similarly we can have user defined functions like a.To create a new file which contains all the contents of pqr.txt except digits using cvtdig(). The name of the new file has to accepted from user. b.To convert the entire file pqr.txt to lower case using a function cvtlwr(). c.To find count of each word of the text file abc.txt using cntwrd(). d.To find the longest sentence using longsent() e.To display the count of alphabets, upper case alphabets, lower case alphabets and digits separately from a file abc.txt using a function cntad(). f.To display the total number of words and number of sentences using a function filedet(). MODULES (ANY RELATED OPERATIONS AS A MODULE) Write two modules a. circlefn – having two functions to find area and perimeter of a circle . b. squarefn – having two functions to find area and perimeter of a square Import these two modules and write a menu driven program having menu options – to find area of circle, perimeter of circle, area of square , perimeter of square. (If the above modules are stored in a folder named measures then it will be a package based question )

MYSQL PYTHON CONNECTIVITY – MINIMUM 4

Write MySql Python connectivity program based on the given table MUSIC: (table and sample data can be created directly using sql, for other than create table question in mysql python connectivity)

+------+---------+------+--------+-------+ | SID | NAME | SEX | INSTR | MFEES | +------+---------+------+--------+-------+ | V9 | ANU P | F | VIOLIN | 350 | | G2 | JOY P | M | GUITAR | 325 | | V3 | PAUL M | M | VIOLIN | 300 | | N4 | ARUN S | M | ORGAN | 400 | | V6 | TOM J | M | VIOLIN | 200 | | N8 | MARIA S | F | ORGAN | 400 | +------+---------+------+--------+-------+ 1. Write a program having user defined functions to perform the following menu options based on the table MUSIC 1. ADD a Student 2. DISPLAY ALL Students 3. Display details of students whose name contains the given substring. . 4. EXIT Similarly we can have menu Options (ANY SQL QUERY) like Display number of students learning each instrument Display students list in the order of their name Display students list in the descending order of Student Id Remove details of student of a given Student Id Change Monthly Fees of a student for a given Student Id Display details of student a given Student Id Display all the tables of the database test *-*-*-*

Get in touch

Social

© Copyright 2013 - 2024 MYDOKUMENT.COM - All rights reserved.