Day 07 - Python Homework

Working with Lists, Sets, and Dictionaries

Today’s assignment will help you practice Python Lists, Sets, and Dictionaries. Use VS Code, create the files, run each program, and check the results.

Don’t forget to use .py extension and test your code by running it in the terminal!

Assignment 01: Student Marks List

Work with Lists to store and process student marks.

Objective:

Learn how to use Python lists to store, modify, and calculate values.

Instructions:

  • Create a list of marks for 5 students.
  • Display all marks using a loop.
  • Find and display the highest, lowest, and average marks.
  • Allow the user to add one more mark and update the list.
  • Display the updated list of marks.

Assignment 02: Unique Subjects (Sets)

Use Sets to manage and display unique subjects chosen by students.

Objective:

Learn how to use sets to remove duplicates and perform operations like union and intersection.

Instructions:

  • Create two sets of subjects chosen by Student A and Student B.
  • Display all unique subjects (Union of sets).
  • Display common subjects (Intersection of sets).
  • Display subjects chosen only by Student A (Difference).
  • Add a new subject to Student B’s set and display the updated set.

Assignment 03: Phonebook (Dictionaries)

Use Dictionaries to create a simple phonebook application.

Objective:

Understand how to use key-value pairs in Python dictionaries.

Instructions:

  • Create a dictionary with 3 contacts (Name → Phone Number).
  • Display all contacts in the phonebook.
  • Ask the user to search for a name and display the phone number if found.
  • Allow the user to add a new contact to the dictionary.
  • Display the updated dictionary.

If you need help

Post in the group with any of these problems:

Good luck and happy coding!