home—info—lects—labs—exams—hws
—D2L—breeze (snow day)—tutor/PIs
lab01-jes-intro
simple integer and string expressions
JES intro
In Python, we have several types of values:
- integers (“ints”):
e.g. 17,
9999,
-5,
0,
23423423432234234
- strings: e.g. "aloha", "Individual characters, strung together!"
-
Start JES (from the Start button, type "JES").
Note:JES is installed in the labs in Davis Hall, but not on other campus computers.
Note:You can download
JES for use on your own computer
(Mac, Windows, Linux; see the “Featured” column on the left).
- Enlarge JES's interactions pane (bottom half).
We won't use the editor pane today (top half).
-
Enter the following expressions in the interactions pane,
and see what each expression evaluates to:
- 2+3
- 2 * 5
- 2 + 3*4
- 4 * 3+2
- 4 * 3+2
- 4 * (3+2)
- 7 - ((2*3) - 1)
- 10 ^ 3 (huh?!)
- 19 (Note that just a number by itself is already a valid expression.)
-
Enter the following expressions in the interactions pane,
and see what each expression evaluates to:
- "hello" (remember the quote-marks)
- "hi" + "there"
- "hi t" + "here" (note the space-character)
- "huh?!" (three space characters)
- "?!" (three space characters)
- " " (three space characters)
- "hel" + "lo st" + "ranger."
-
Enter the following expressions in the interactions pane,
and see what each expression evaluates to:
- hello (note that we're omitting the quote-marks around hello)
- "hello" + 3
- 2+[3*4] (note the square-brackets instead of parens)
- 2+3)*4 (note the missing open-paren)
- 2+(3*4 (note the missing close-paren)
Which error message above was the most helpful?
Which was the least helpful?
-
Create an expression that evaluates to 120, using only
*,
and the integers
2,
3
and
5.
(You may use some of the integers more than once.)
One solution: 2*3*2*2*5
-
TODO
Create an expression that evaluates to 11, using only
+,
and the integers
3
and
4.
(You may use some of the integers more than once.)
-
TODO
Create an expression that evaluates to "Monty Python", using only
+,
and the strings
"tho",
"n",
"Mo",
"ty Py",
and
" ".
(You may use some of the strings more than once.)
-
TODO
Evaluate the following statements (typing them in yourself -- no copy/pasting):
temp = 16
temp
temp+5
sunny = 12
temp + sunny
temp
reaction = "Brrr"
"zo" + "mbies seek " + reaction + "ains!!"
|
home—info—lects—labs—exams—hws
—D2L—breeze (snow day)—tutor/PIs