Neural Sync Active
jan-2026-python-week-7-numbers-2
Registry Synced
jan-2026-python-week-7-numbers-2
590 words
3 min read
Numbers 2
Course: Jan 2026 - Python
Numbers 2
Submission deadline has passed for this assignment
Due Apr 01, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
2/2 Passed
Submitted on Apr 01, 2026 at 3:46 AM IST
Private Tests
2/2 Passed
Submitted on Apr 01, 2026 at 3:46 AM IST
**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Create a dictionary with elements in the list as values and the indices as keys.**
Given a list of items, create a dictionary with the indices as keys and the items as items.
Template Code(Click to Expand)
def create_indexed_dict(items: list) -> dict: ''' Given a list of items, create a dictionary with the indices as keys and the items as items. Args: items (list): A list of items. Returns: dict: A dictionary with indices as keys and items as items. ''' ...
NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.
Public Tests ( 2/2 )
Case 1
Input:
textnames1 = ["Alice", "Bob", "Charlie", "David"] expected1 = {0: "Alice", 1: "Bob", 2: "Charlie", 3: "David"} is_equal(create_indexed_dict(names1), expected1)
Case 1
Expected Output:
text{0: 'Alice', 1: 'Bob', 2: 'Charlie', 3: 'David'}
Case 1
Actual Output:
text{0: 'Alice', 1: 'Bob', 2: 'Charlie', 3: 'David'}
Case 2
Input:
textnames1 = ["Apple", "Banana", "Cherry", "Date"] expected1 = {0: "Apple", 1: "Banana", 2: "Cherry", 3: "Date"} is_equal(create_indexed_dict(names1), expected1)
Case 2
Expected Output:
text{0: 'Apple', 1: 'Banana', 2: 'Cherry', 3: 'Date'}
Case 2
Actual Output:
text{0: 'Apple', 1: 'Banana', 2: 'Cherry', 3: 'Date'}
Private Tests ( 2/2 )
Case 1
Input:
textnames = ["Eve", "Frank", "Grace", "Hank", "Ivy"] expected = {0: "Eve", 1: "Frank", 2: "Grace", 3: "Hank", 4: "Ivy"} is_equal(create_indexed_dict(names), expected)
Case 1
Expected Output:
text{0: 'Eve', 1: 'Frank', 2: 'Grace', 3: 'Hank', 4: 'Ivy'}
Case 1
Actual Output:
text{0: 'Eve', 1: 'Frank', 2: 'Grace', 3: 'Hank', 4: 'Ivy'}
Case 2
Input:
textnames = ["Jack", "Kathy", "Leo"] expected = {0: "Jack", 1: "Kathy", 2: "Leo"} is_equal(create_indexed_dict(names), expected)
Case 2
Expected Output:
text{0: 'Jack', 1: 'Kathy', 2: 'Leo'}
Case 2
Actual Output:
text{0: 'Jack', 1: 'Kathy', 2: 'Leo'}
💻 IITM Official Solution
pythondef create_indexed_dict(items: list) -> dict: ''' Given a list of items, create a dictionary with the indices as keys and the items as items. Args: items (list): A list of items. Returns: dict: A dictionary with indices as keys and items as items. ''' # basic approach d = {} for i in range(len(items)): d[i] = items[i] return d # other approaches # using comprehensions # return {i: item for i, item in enumerate(items)} # functional # return dict(enumerate(items))
💻 My Submitted Code
pythondef create_indexed_dict(items: list) -> dict: # Option 1: Dictionary Comprehension # return {i: items[i] for i in range(len(items))} # Option 2: Using enumerate (Cleaner/Pythonic) return dict(enumerate(items))