COMP-200: Intro to Computer Systems
Assignment 4
mo khan - 3431709
Choose ONE exercise each from Chapters 10, 11, and 12. There are no chapter end exercises for Chapter 9.
Chapter 10:
- In Python, indentation is used to indicate the extent of a block of code. What is the output of the following Python code?
!include assignments/4/main.py
$ python assignments/4/main.py
second is bigger
first is bigger
Chapter 11:
-
Identify the tokens in each of the following statements. (You do not need to classify them; just identify them.) a.
if (a == b1) a = x + y;token type if if condition ( left paren a symbol == comparison operator b1 symbol a symbol = assignment operator x symbol + addition operator y symbol ; statement terminator b.
delta = epsilon + 1.23 - sqrt(zz);token type delta symbol = assignment operator epsilon symbol + addition operator 1.23 floating point number - subtraction operator sqrt symbol ( left paren zz symbol ) right paren ; statement terminator c.
print(Q);token type print symbol ( left paren Q symbol ) right paren ; statement terminator
Chapter 12:
- Given the Turing machine instruction
(1,1,0,2,L)and the configuration...b 1 0 b...draw the next configuration.
(1,1,0,2,L)- Move left once and halt the machine
--------|*|----------
|.|.|.|b|1|0|b|.|.|.|
--------|*|----------
^
|- 1
------|*|------------
|.|.|.|b|0|0|b|.|.|.|
------|*|------------
^
|- 2