Referenced from lesson If-Expressions
1) Open the Mood Generator starter file, and read through the code you find there. This code contains new programming that you haven’t seen yet! Take a moment to list everything you Notice, and then everything you Wonder…
Notice | Wonder |
---|---|
|
2) Add another line of code to the definition, so that mood("mad")
produces the same emoji as mood("angry")
.
3) Add another example to the examples:
section for "laughing", using the appropriate emoji. (To bring up the emojis on your computer, type Cmd-Ctrl-Space
on a Mac, or Windows-Period
on Windows 10)
4) Come up with some new moods, and add them to the code. Make sure you include examples:
!
5) In your own words, how do if-expressions work in Pyret? Write your answer below.
6) Write down at least 2 ways you could use if-expressions when analyzing the Animals Dataset.
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap:Data Science by Emmanuel Schanzer, Nancy Pfenning, Emma Youndtsmith, Jennifer Poole, Shriram Krishnamurthi, Joe Politz, Ben Lerner, Flannery Denny, and Dorai Sitaram with help from Eric Allatta and Joy Straub is licensed under a Creative Commons 4.0 Unported License. Based on a work at www.BootstrapWorld.org. Permissions beyond the scope of this license may be available by contacting schanzer@BootstrapWorld.org.