Weird Cases in Lists
This quiz is not graded. By this point, we do not assume you know the answers to all of these questions, and we encourage you to make a best guess for each question. We also want to reinforce that the answers to these questions will be important later on, but that you can figure them out whenever you need to!
The questions in this quiz are essentially “what does this do?” questions. When dealing with these questions, you must realize that people designed every programming language. So, people weighed pros and cons and made a decision about what the language should do in each situation (its specifications). You might disagree with them about what should happen, but it is important to realize that you can always test code to figure out what it does.
The following questions test boundary cases, where what the code should do is not intuitive.
1) Assuming that you only have five elements in your players list, what would happen if you ran the script below?
- “thing” will be added to the end of the list
- “thing” will be added to the beginning of the list
- The list will remain unchanged
- Blank entries will be added to the list so that the new element can be inserted at the index specified
2) Are the words in a list case-sensitive? In other words, is “Thing” different from “thing"?
3) What happens when you run the script below with a list that has no elements?
- The block will report a blank.
- The block will turn red and there will be an error.
- The block will report the item that was most recently at the specified index.
- The block will not run.
4) What gets added to players when you run the following script?