Skip to content
RonitMehta08Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

📘 Study of Dictionary in Python

File: exp5.ipynb
Experiment: Study of Dictionary in Python

Name: Ronit Mehta

PRN: 25070123094


🎯 Aim

To study and implement Python Dictionaries


📖 Theory

A dictionary in Python is an unordered collection of data stored in key–value pairs, enclosed within curly braces {}.

Key properties of Python dictionaries:

  • Store elements as key–value pairs
  • Keys must be unique and immutable
  • Values can be of any data type
  • Dictionaries are mutable (elements can be added, updated, or removed)
  • Accessing elements is done using keys rather than indexing
  • Provide built-in methods like get(), update(), pop(), keys(), and values()

Dictionaries are widely used for structured data storage, fast lookup operations, and real-world applications such as login systems, student databases, and product management.


🧠 Algorithm (Cell-wise)

Cell 1 – Creating a Dictionary

  1. Create a dictionary containing car details such as brand, model, and year.
  2. Display the dictionary.

Cell 2 – Accessing Dictionary Elements

  1. Create a dictionary with car details.
  2. Access the value of a specific key (brand).
  3. Display the retrieved value.

Cell 3 – Handling Duplicate Keys

  1. Create a dictionary with duplicate keys (year).
  2. Display the dictionary.
  3. Observe that the latest value overwrites the previous one.

Cell 4 – Finding Dictionary Length

  1. Use the len() function on the dictionary.
  2. Display the total number of key–value pairs.

Cell 5 – Checking Dictionary Type

  1. Create a dictionary.
  2. Use the type() function to verify its data type.
  3. Display the result.

Cell 6 – Updating a Dictionary

  1. Create a dictionary named car.
  2. Add a new key (color) using the update() method.
  3. Display the updated dictionary.
  4. Retrieve and display all values using values().

Cell 7 – Using get() and pop()

  1. Create a dictionary containing student details.
  2. Retrieve the student's name using the get() method.
  3. Remove an element (branch) using pop().
  4. Display the modified dictionary.

Cell 8 – Updating Product Price

  1. Create a dictionary representing product prices.
  2. Modify the price of an existing product (Mouse).
  3. Display the updated dictionary.

Cell 9 – Searching for Student Marks

  1. Create a dictionary with student names and marks.
  2. Accept user input to search for a student's marks.
  3. Use the get() method to safely retrieve the value.
  4. Display the result.

Cell 10 – Simple Login Validation

  1. Create a dictionary storing usernames and passwords.
  2. Accept username and password as input.
  3. Check whether the username exists in the dictionary.
  4. Validate the password and display appropriate messages.

Cell 11 – Finding the Topper

  1. Create a dictionary containing student marks.
  2. Use max() with key=marks.get to find the highest scorer.
  3. Display the topper's name along with their marks.

✅ Conclusion

This experiment demonstrates the effective use of Python Dictionaries for storing and managing structured data. It highlights essential operations such as accessing values, updating records, removing elements, and performing searches efficiently.

The experiment also showcases practical applications like product updates, login validation, and student performance tracking, making dictionaries one of the most powerful and commonly used data structures in Python.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages