Students will gain experience writing code in the agnostic language of AP CSP
The objective of this lesson is to provide students with exposure to the agnostic coding language used in the AP CSP exam through a coding task. Additionally, this task is meant to prepare students for the first sprint of their ARC Challenge.
Activity 6.7.1 (55 minutes)
Students should be provided with a copy of the AP CSP exam reference sheet
Students should write a script that does the following:
create an empty list assigned to a variable named songs
add file names song1, song2, and song3 to this list
remove the 2nd element of the list
define a procedure named addSong that takes in the fileName of a song as an argument. This procedure should:
if the length of the list is less than 10, adds this fileName to the end of songs
otherwise, remove the first element of the list before adding fileName to the end of songs
define a procedure named addSongs that takes in two lists listA and listB as arguments. This procedure should:
append all the elements contained in listB to the end of listA
if the combined lengths of listA and listB exceeds 10, remove enough elements from the beginning of listA to make room for listB's elements
listA will always have more elements than listB
stores the combined list in songs