Page 263 - Learn To Program With Scratch
P. 263

try it out 9-11
           USMapQuiz .sb2   Open this application and test it . Then, think of other quizzes in different subject
                            areas that you can create and implement them . One example, shown below, is
                            provided in the file USMapQuiz.sb2 . Open this file and complete the missing parts
                            to make this quiz work .




                                             a
                                       c
                                                  f
                                             b
                                        h
                                              d

                                          i  g

                                                  e









            SortEmOut .sb2   The second application is a program that spells whole numbers. It
                          prompts the user to input a number and then says that number in words.
                          If the user inputs 3526, for example, the program will say “three thousand
                          five hundred twenty six.” The idea is to break the number, from right to left,
                          into groups of three digits. Each group is then spelled out with a multiplier
                          word (thousand, million, and so on), if needed.
                Sieve .sb2   The third program demonstrates the sieve of Eratosthenes, an algorithm
                          for finding all prime numbers less than 100.


               Summary

                          Lists are extremely useful in programming, and they provide a convenient
                          way to store multiple elements. In this chapter, we explored creating lists
                          in Scratch, learned the commands we can use to deal with them, and prac-
                          ticed populating lists dynamically with data entered by the user.
                             We also examined numerical lists and demonstrated how to find the
                          minimum, the maximum, and the average value of their elements. After
                          that, we learned simple algorithms for searching and sorting lists. We con-
                          cluded the chapter with several programs that demonstrated the use of lists
                          in practical applications.




                                                                                      Lists   241

                                           www.it-ebooks.info
   258   259   260   261   262   263   264   265   266   267   268