This is our second to last scratch lab. In this lab we learned about lists, which are more powerful than variables.
This time on our pair programming assignment, we had to make use of lists in order to find the sum of a bunch of randomly generated numbers. Using the lists was strange and hard to get used to at first, however afterwards, we were able to solve the problem. We only had two problems this time because of the complexity of lists, and I was only able to finish one.
In this problem we used lists in order to make a calculator which checks to see if a number is prime or not. All odd numbers that are divided by two end up with a .5 at the end of the number. So I created a list with all whole numbers up to 50,000, because that is the maximum possible sum for the numbers. The program then checks to see if the provided number is even or odd. The second part of the problem involved creating a custom block that did the whole even/odd process. Using the custom block, I was able to track the amount of even and odd numbers in the list. If the number of even numbers exceeds the number of odd numbers in the end, the costume of the sprite changes.
What is the length of an "empty" list?
The length of an empty list is 0.
Why are lists more powerful than variables
Lists can contain and store more values than variables.
Can lists contain different data types? For example, could it store both numbers and words?
Yes, a list can store numbers and words at the same time.