← Back to Lists
Question 151
Passing Grades Only
Passing Grades Only
Declare the list grades as [74, 88, 91, 65, 79, 40, 32, 30] and read the pass mark as one integer from input() with no prompt. With one for loop and an if / else, build two new lists by concatenation with + (no list methods): passed holding every grade at or above the pass mark and failed holding the rest, both in original order. Then print three lines: Passed: <list>, Failed: <list> and <p> passed and <f> failed using len() for the two counts. An empty list prints as []. Input: one integer.
Expected Output:
Passed: [74, 88, 91, 65, 79] Failed: [40, 32, 30] 5 passed and 3 failed
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
ListsOperators
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.