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

Python Assignment3

The document outlines a Python assignment consisting of multiple sections focusing on lists, tuples, sets, and dictionaries. Each section contains specific questions that require coding, sample input/output, and explanations of concepts related to data structures. The assignment emphasizes the importance of providing explanations to earn marks.

Uploaded by

collabxadarsh
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 views4 pages

Python Assignment3

The document outlines a Python assignment consisting of multiple sections focusing on lists, tuples, sets, and dictionaries. Each section contains specific questions that require coding, sample input/output, and explanations of concepts related to data structures. The assignment emphasizes the importance of providing explanations to earn marks.

Uploaded by

collabxadarsh
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

Python Assignment–3

Instructions:
- Write code, sample input/output (your own data), and explanation.
- Use your name/roll number in programs.
- No explanation = 0 marks.

SECTION A: LISTS (4 Questions)

Q1. Personalized Marks Analyzer


Store marks of 5 subjects (user input) in a list.

• Find:
o Highest
o Lowest
o Average
• Note: Replace lowest mark with your roll number’s last digit

• Explain: Why list is suitable here?

Q2. Dynamic Shopping Cart


Create a list of items purchased by user.

• Allow:
o Add item
o Remove item
o Display cart
• Use loop (menu-driven)
• Note: Maximum items allowed = last digit of your roll number
• Explain: How list is modified dynamically?

Q3. Duplicate Removal Without Set


Take a list of numbers from user.

• Remove duplicates without using set

Explain: Logic used to detect duplicates


Q4. List Rotation Logic
Take a list and rotate elements:

• Left rotation by N positions


• N = number of vowels in your name
• Explain: How indexing works here?

SECTION B: TUPLES (4 Questions)

Q5. Student Record System (Immutable Logic)


Store:
• Name, Roll, Branch, CGPA in a tuple
• Try modifying CGPA → show error
• Explain: Why tuple is immutable?

Q6. Tuple-Based Data Packing


Take 3 values:
• Temperature, Humidity, Pressure
• Store in tuple and unpack them
• Twist: Print values in reverse order
• Explain: Tuple unpacking concept

Q7. Tuple Comparison


Take two tuples of numbers
• Compare:
o Sum
o Maximum value
• Output which tuple is “stronger”
• Explain: Why tuple is useful for fixed data?

Q8. Nested Tuple Analysis


Create tuple containing:
• (name, (marks1, marks2, marks3))
• Calculate total marks
• Explain: Accessing nested elements
SECTION C: SETS (4 Questions)

Q9. Unique Visitor Tracker


Take names of visitors (multiple entries allowed)
Use set to:
• Remove duplicates
• Display unique visitors
Explain: Why set removes duplicates?

Q10. Common Subjects Finder


Take 2 sets:
• Subjects of Student A
• Subjects of Student B
Find:
• Common subjects
• Unique subjects
Explain: Set operations used

Q11. Random Number Filter


Generate list of numbers (user input)
Convert to set
Display only:
• Unique even numbers
Explain: Combination of set + condition

Q12. Set Membership Checker


Take a set of numbers
Check:
• Whether a number exists or not
Explain: How set lookup is faster?

SECTION D: DICTIONARIES (4 Questions)

Q13. Student Marks Dictionary


Create dictionary:
• {subject: marks}
Find:
• Total
• Average
• Grade
Explain: Why dictionary is better than list?
Q14. Phone Directory System
Store:
• Name → Phone number
Operations:
• Add contact
• Search contact
• Delete contact
Explain: Key-value advantage

Q15. Word Frequency Counter


Take a sentence
• Count frequency of each word
Use dictionary
Explain: How keys are created dynamically?

Q16. Employee Salary Manager


Store:
• Employee name → salary
Find:
• Highest salary employee
Explain: Traversing dictionary

SECTION E: MIXED (LIST + TUPLE + SET + DICTIONARY)

Q17. Smart Data Processing System


Design a system where:
• Input: Student names and marks
Use:
• List → store raw data
• Tuple → store final (name, grade)
• Set → unique grades
• Dictionary → mapping name → marks
Output:
• Topper
• Unique grades
• Sorted results
Mandatory:
• Use at least one loop + one condition
Explain:
• Why each data structure is used

You might also like