Referenced from lesson Simple Data Types
Make sure you’ve loaded the code.pyret.org, (CPO) editor, clicked “Run”, and are working in the Interactions Area.
Numbers
1 Try typing 42
into the Interactions Area and hitting “Enter”. What is the largest number the editor can handle?
2 Try typing 0.5
. Then try typing .5
. Then try clicking on the answer. Experiment with other decimals. Explain what you understand about how decimals work in this programming language.
3 What happens if you try a fraction like 1/3
?
4 Try writing negative integers, fractions and decimals.
Strings
String values are always in quotes.
5 Is 42
the same as "42"
? Why or why not? Write your answer below:
6 Try typing your name (in quotes!).
7 Try typing a sentence like "I’m excited to learn to code!" (in quotes!).
8 Try typing your name with the opening quote, but without the closing quote. Read the error message!
9 Now try typing your name without any quotes. Read the error message!
10 Explain what you understand about how strings work in this programming language.
Operators
11 Just like math, Pyret has operators like +,
-,
*
and /
. Try typing in 4 + 2,
and then 4+2
(without the spaces). What can you conclude from this?
12 Type in the following expressions, one at a time: 4 + 2 + 6,
4 + 2 * 6,
4 + (2 * 6)
. What do you notice?
13 Try typing in 4 + "cat",
and then "dog" + "cat"
. What can you conclude from this?
These materials were developed partly through support of the National Science Foundation,
(awards 1042210, 1535276, 1648684, and 1738598).
Bootstrap:Algebra by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.