Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 2.31 KB

File metadata and controls

67 lines (51 loc) · 2.31 KB

Lab 1.02 - Using the Interpreter

Part 1

Using the interpreter, type in the expressions below. Copy and paste the output into the output column. If the result is unexpected, note that in the third column.

Section 1

Input Output Did it do something unexpected?
a 5 + 2 * 2
b 2/3
c 2.0 * 1.5
d (2 + 3) * 10
e 5.0 // 2
f 5.0 % 2

Section 2

Input Output Did it do something unexpected?
a a
b 'a'

Section 3

Input Output Did it do something unexpected?
a 'a + b'
b 'a' + 'b'

Section 4

Input Output Did it do something unexpected?
a 'a' * 'b'
b 'a' * 2

Part 2

Before going to the IDE

  1. For each item, predict the data type of the result and enter into the "String/Integer/Float" column.
  2. Next, predict the value of the result for each item and enter into it into the "Prediction of Result" column.
Expression String/Integer/Float Prediction of Result Interpreter Result
a 10 * 2 integer 20 20
b .5 * 2
c 10/2
d 10%2
e 2 ** 3
f (2+5)*3
g 2 + 5 * 3
h 'ab' + '12' + '3'
i x
j "ab" + "cd"
k 'abc' * 2
l '1'*2 + '2' * 3
m 1 * 2 + '3' * 2
n 'A' ** 2
o 'bc' % 2
p 'bc' / 2

Now go to the IDE

Use the interpreter to evaluate the expressions, write down results in the "Interpreter Result" column.