Welcome to the Python Dictionary reference! This README answers frequently asked questions, provides technical and programming exercises (especially on Lists), and helps you maximize this repository.
- What is a dictionary in Python?
- How do you create a dictionary?
- What is the difference between a list and a dictionary?
- How do you access values in a dictionary?
- How do you add or update key-value pairs?
- What happens if you try to access a missing key?
- How do you safely access a key that might not exist?
- How do you remove a key-value pair from a dictionary?
- How do you iterate over keys and values?
- How do you merge two dictionaries?
- What is a dictionary comprehension?
- How do you copy a dictionary?
- How do you check if a key exists?
- What are dictionary views (
keys(),values(),items())? - Are dictionaries ordered?
- Can dictionary keys be mutable?
- How do you clear a dictionary?
- How do you get the number of items in a dictionary?
- How do you use default values with
get()? - How do you create a nested dictionary?
- What is the difference between a list and a tuple?
- How do you append an element to a list?
- How do you remove an element from a list?
- How do you slice a list?
- How do you concatenate lists?
- How do you check membership in a list?
- How do you find the index of an element?
- How do you reverse a list?
- How do you sort a list (ascending/descending)?
- What is list comprehension?
- Write a program to find the largest/smallest element in a list.
- Write a program to remove duplicates from a list.
- Count the number of occurrences of each element in a list.
- Find the sum and average of all elements in a list.
- Merge two lists into a single list.
- Check if two lists have any elements in common.
- Flatten a nested list structure.
- Split a list into even and odd numbers.
- Reverse the order of a list in-place.
- Rotate a list by k steps.
- For Learners:
- Study the provided questions as quick interview prep or concept revision.
- Practice answering the programming exercises to improve coding skills.
- Use the technical questions to deepen understanding of lists and their use in Python.
- For Interviewers:
- Select questions for technical interviews or coding assignments.
- For Contributors:
- Add more questions or sample code snippets as pull requests.
- Improve explanations, solutions, or provide real-world examples.
Stay tuned for solutions and code examples!