Python: Print subject name and marks in order of its first occurrence
6. Accept subjects, names, and marks, then print in order
Write a Python program that accepts the number of subjects, subject names and marks. Input the number of subjects and then the subject name and marks separated by a space on the next line. Print the subject name and marks in order of appearance.
Sample Solution:
Python Code:
Sample Output:
Powered by Number of subjects: 3 Input Subject name and marks: Bengali 58 Input Subject name and marks: English 62 Input Subject name and marks: Math 68 Bengali 58 English 62 Math 68
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to prompt the user for a number of subjects, then read subject names and marks, and finally print them as a formatted table.
- Write a Python program to store subject names and marks in a dictionary and then print each subject with its mark in order of input.
- Write a Python program to use list comprehension to collect subject-mark pairs and display them sorted by subject name.
- Write a Python program to implement a function that reads subjects and marks and returns a list of tuples preserving the order of input.
Go to:
Previous: Write a Python program that accept some words and count the number of distinct words. Print the number of distinct words and number of occurrences for each distinct word according to their appearance.
Next: Write a Python program to create a deque and append few elements to the left and right, then remove some elements from the left, right sides and reverse the deque.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.