Explanation:
How this Program Works: This program acts like a digital ledger. It repeatedly asks for a name and a score, stores them together, and stops only when you tell it to. How the Code Works: d = dict(): Sets up an empty "dictionary" to store your data. while True:: Starts a loop that repeats indefinitely so you can enter multiple students. d[key] = value: Links the name (key) to the marks (value) inside the dictionary. .capitalize(): Standardizes the user's answer (e.g., "no" becomes "No") so the program correctly recognizes when to stop. break: Exits the loop and stops asking for input. print(d): Displays the final list of all names and marks collected. Key Concepts for Beginners: Dictionaries: Store data in pairs, like a real dictionary links a word to its definition. Inputs: By default, input() treats everything as text. We use int() to convert marks into a number. Loops: The while loop is the "engine" that keeps the program running until the break condition is met.
d = dict()
while True:
key = input("Enter the Name: ")
value = int(input("Enter the marks: "))
d[key] = value
option = input("Do you want to add one more student? Yes || No\n")
if option.capitalize() == 'No':
break
print(d)