361,594 views
29 votes
29 votes
Write a program called playwaltz.py that accepts from standard input, a sequence of 32 integers representing the 32 measures of a waltz, and plays the waltz to standard audio. Before playing any audio, your program must check if the inputs are correct, and if they are not, must call sys.exit(message) to exit the program with an appropriate error message. The following errors must be handled:

• If the number of measures is not 32, exit with the message "A waltz must contain exactly 32 measures".
• If a minuet measure is not from [1,176], exit with the message "A minuet measure must be from 1, 176)".
• If a trio measure is not from (1,96), exit with the message "A trio measure must be from (1, 96)"

User Dnsh
by
2.9k points

2 Answers

10 votes
10 votes

Final answer:

The program playwaltz.py checks the correctness of inputs and plays a waltz to standard audio

Step-by-step explanation:

playwaltz.py

To write the program playwaltz.py, you can use a programming language like Python. The program should accept a sequence of 32 integers as input, which represent the 32 measures of a waltz. Before playing any audio, the program needs to check if the inputs are correct. If the number of measures is not exactly 32, the program should exit with the error message 'A waltz must contain exactly 32 measures'. If a minuet measure is not between 1 and 176 (both inclusive), the program should exit with the error message 'A minuet measure must be from 1 to 176'. If a trio measure is not between 1 and 96 (both exclusive), the program should exit with the error message 'A trio measure must be from 1 to 96'.

User Adamdehaven
by
3.2k points
11 votes
11 votes

thats a lot of damage Step-by-step explanation:

User Rob Horton
by
2.3k points