This course has already ended.
You cannot submit this assignment

You need to sign in and enrol to submit exercises.

Assignment 7

2 points

You can also “multiply” a string by a number. For instance, you can form these expressions:

"nefer" * 3
"Under my umbr" + "-ella" * 3 + ", eh" * 3

Which of the following claim(s) about those two expressions are correct? Program in the REPL and find out!

4 points

Try the following:

play("<cccedddfeeddc---")play(">>>" + "cccedddfeeddc---")play("ccceddd>feedd<<<c---")

play has been defined to let you change octaves: notes that follow the > character will be played at a higher pitch than the ones that precede it; notes that follow < will be played at a lower pitch. Multiple octave-change marks cause a more dramatic change; for instance, the second of the three examples above plinks out Ukko Nooa three octaves higher.

Use the string operators + and * to pastiche the shark attack motif from the movie Jaws. To be more specific, use the operators to form an expression that evaluates to a string that contains exactly the following:

  • first, three < characters to lower the sounds that follow by three octaves (these three at the beginning should be the only <s in the entire string); then

  • the pair of notes "ef" repeated sixteen times; and finally

  • the upper-case pair of notes "EF" repeated eight times.

In the REPL, try entering just the expression. Also try passing the expression as a parameter to play.

If you struggle with this assignment, the first thing is to check your double quotes. Place each component string in quotation marks! It can also be a good idea to print out the string you produced rather than playing it, so that you can examine it visually. And remember that the lab sessions/Piazza/Telegram are there to help you.

Reap the rewards by entering the String-valued expression, operators and all, below. Please enter just the expression, not a command that plays it. Include the operators; don’t enter the longer string that the expression evaluates to.

Posting submission...

Earned points

0 / 6

Exercise info

Assignment category
Graded
Your submissions
0 / 5
Deadline
Wednesday, 14 September 2022, 18:00
Late submission deadline
Saturday, 15 April 2023, 12:00 (-100%)
Group size
1-2
Total number of submitters
1049