Over 10 years we helping companies reach their financial and branding goals. Onum is a values-driven SEO agency dedicated.

CONTACTS
ECET 2026 CSE

Day 51 – Night Session: Python – Dictionaries: Keys, Values, Loops – ECET 2026

In ECET 2026 CSE, Python questions are very common. Dictionaries are one of the most important data structures in Python because they store data in key-value pairs. Understanding how to work with keys, values, and loops can fetch direct marks in exams.


📘 Concept Notes

🔑 What is a Dictionary?

  • A dictionary in Python is an unordered, mutable collection of key-value pairs.
  • Syntax:
dict_name = {key1: value1, key2: value2, ...}
  • Keys must be unique and immutable (string, number, tuple).
  • Values can be of any data type.

⚙️ Accessing Keys & Values

student = {"name": "Ravi", "age": 20, "branch": "CSE"}

print(student["name"])   # Access value by key → Ravi
print(student.get("age"))  # Safe access → 20
  • Keys() Method: Returns all keys.
print(student.keys())  # dict_keys(['name', 'age', 'branch'])
  • Values() Method: Returns all values.
print(student.values())  # dict_values(['Ravi', 20, 'CSE'])
  • Items() Method: Returns key-value pairs.
print(student.items())  
# dict_items([('name', 'Ravi'), ('age', 20), ('branch', 'CSE')])

🔄 Loops in Dictionaries

  1. Loop over keys
for key in student:
    print(key)
  1. Loop over values
for value in student.values():
    print(value)
  1. Loop over key-value pairs
for key, value in student.items():
    print(key, ":", value)

📐 Example

marks = {"Maths": 95, "Physics": 88, "Chemistry": 92}

for subject, score in marks.items():
    print(subject, "", score)

Output:

Maths → 95
Physics → 88
Chemistry → 92

🔋 Formula (for exams with storage/size concepts)

If:

  • Dictionary has  n keys,
  • Each key takes  K bytes,
  • Each value takes  V bytes,

Then approx memory size =

 \text{Size} \approx n \times (K + V)


🔟 10 Expected MCQs – ECET 2026

Q1. Python dictionaries store data in:
A) Index-value pairs
B) Key-value pairs
C) Value-only pairs
D) Ordered sequences

Q2. Which method returns only dictionary keys?
A) keys()
B) values()
C) items()
D) get()

Q3. Which of the following is NOT a valid key in a dictionary?
A) String
B) Tuple
C) List
D) Integer

Q4. To safely access a dictionary value without error, use:
A) []
B) get()
C) keys()
D) items()

Q5. If d = {"a": 1, "b": 2}, what does d.items() return?
A) [‘a’, ‘b’]
B) [1, 2]
C) dict_items([(‘a’, 1), (‘b’, 2)])
D) Error

Q6. Output of:

d = {"x": 10, "y": 20}
for k in d:
    print(k)

A) 10 20
B) x y
C) dict_keys([‘x’, ‘y’])
D) Error

Q7. Which method gives both keys and values?
A) values()
B) items()
C) get()
D) update()

Q8. In Python, dictionary keys must be:
A) Mutable
B) Immutable
C) Both
D) None

Q9. If dictionary has 5 keys, each 4 bytes, values 8 bytes → memory size = ?
A) 20 bytes
B) 40 bytes
C) 60 bytes
D) 120 bytes

Q10. Which is TRUE for dictionaries?
A) Ordered always
B) Duplicates allowed in keys
C) Mutable collection
D) Can’t store mixed data types


✅ Answer Key

Q.NoAnswer
Q1B
Q2A
Q3C
Q4B
Q5C
Q6B
Q7B
Q8B
Q9C
Q10C

🧠 Explanations

  • Q1 → B: Dictionaries = key-value pairs.
  • Q2 → A: keys() gives only keys.
  • Q3 → C: List is mutable, cannot be a key.
  • Q4 → B: get() prevents KeyError.
  • Q5 → C: Returns dict_items object.
  • Q6 → B: Iteration gives keys → x, y.
  • Q7 → B: items() returns key-value pairs.
  • Q8 → B: Keys must be immutable.
  • Q9 → C:  5 \times (4+8) = 60 bytes.
  • Q10 → C: Dictionaries are mutable.

🎯 Why Practice Matters

  • Python dictionary questions are direct and syntax-based.
  • Easy 1–2 marks if you know methods and looping structure.
  • Frequently repeated in ECET past papers.

📲 Join Our ECET Prep Community on WhatsApp

👉 Join WhatsApp Group – Click Here

Leave a comment

Your email address will not be published. Required fields are marked *