0% found this document useful (0 votes)
24 views10 pages

2 Py

python programs

Uploaded by

23517093
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
24 views10 pages

2 Py

python programs

Uploaded by

23517093
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
LAB ASSIGNMENT 6 Dictionaries & Sets 1. Create a dictionary to store information about students. Each student should have a Roll no, name, age, and grade. Implement a loop to allow the user to input details for multiple students. Consider roll no as the key. Code: - SoC ead CeeCry Pesta coe Peon Output: - the information stored in the dictionary for a given student Q1). Handle cases where the user enters the name of a nary. Output: - ar Season ccna Pea oenEC acy Sources eee Sac Cone He Sean eC 3. Allow the user to update the information for a specific student entering the rollno (consider dictionary created in Q1). For example, enter 1 to change the name, 2 to change the age and 3 to change the grade of a student, 4 to remove the specified rollno ssert a new rolino. ear Cae ny input ("Ent Sano Peat Serra ete Con ee ore eC EC eee eects en eee cd Poe Poem Pea eae Une ee Cs Sree eco reed ee ne eee) Surat ote eee eee ae -Ceae CA le ENa 4. Input the name and birthday month of unlimited no. of students in numerical format e.g. For birthday month as February, the user should input 2. An error should be displayed if the user enters a wrong birthday month, not in series 1-12. Print the details of all students except those born in February, in the following format: Ashok, you were born in July. Code: - once cere Bara rthday month (1-12) Peete See ances Perea wane t} Pome eres) ore Geet Peet eie et eee eee Cec Umea PON n rts Soe en ea eases See ee eae ts 5. Create a set contai is unique. ing the favorite colors of a group of friends. Ensure that each color Output: - 6. Allow the user to add or remove colors from the set (consider the set created in (Q5). Code: - sary erates 7. Create two sets of numbers and find the common elements between them. Display the common elements along with their frequency. Pectrcd oS eT eee se me at eed) Output: - en eon erat Cre eure DO eae Mra PTT LNT lola ace (O(a Loy Number: 5, Frequency 8. There is an indoor activity club that offers classes for painting, chess, dance and yoga. Create the sets for each class by the names of the members. For example: painting_members = {‘Alice’, ‘Bob’, ‘Charlie’, ‘David'} chess_members = (‘Alice’, ‘Eve’, ‘Frank’, 'David'} dance_members = {Alice’, ‘Bob’, ‘Grace’, ‘David'} yoga_members = {‘Eve’, ‘Frank’, 'Grace'’, 'Harry'} The owner of the club needs the following lists: a. List of all unique members b, Members who have enrolled for all the four courses ¢. Members who have enrolled for dance but not yoga d, Members who have enrolled for either painting or chess but not both e. Ensure that dance and yoga have no common participants Code: - rT: eel PSR Ee

You might also like