livepython.net

129. Python Program to Make a Class Attendance Report

HardWhich one?

Overview

Put the whole chapter together: tuples for records, sets to drop repeats, unpacking in a loop, and a dictionary to count.

Problem Statement

A teacher types who was in class: one line per student per day, a name and a day separated by a space, like Sunny Mon, until done. The same line may be typed twice by mistake; count it only once.

Print:

  1. Days: and how many different days appear.
  2. For every student, in A to Z order: the name and on how many of those days they were present, like Lucky: 2 of 3 days.
  3. Every day: and the students present on every day, in A to Z order, joined with a comma and a space, or nobody.

For example:

Days: 3
Lucky: 2 of 3 days
Rocky: 3 of 3 days
Sunny: 3 of 3 days
Every day: Rocky, Sunny

If the first line is already done, print only:

No attendance

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One line per student per day; the last line is always done. Example:

Sunny Mon
Rocky Mon
Sunny Tue
Rocky Tue
Lucky Tue
Sunny Wed
Rocky Wed
Lucky Wed
done

Output

The output for that example:

Days: 3
Lucky: 2 of 3 days
Rocky: 3 of 3 days
Sunny: 3 of 3 days
Every day: Rocky, Sunny

The tests try 4 different inputs.

Learn this firstChapter 14 · List vs Tuple vs Set vs Dictionary in Python
solution.py
# write your code here

EXPECTED OUTPUT

1Days: 3
2Lucky: 2 of 3 days
3Rocky: 3 of 3 days
4Sunny: 3 of 3 days
5Every day: Rocky, Sunny

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.