## Exercise
- Run the above program in Mars, observe the output
- Change it so `i` and `j` are equal, run again
- Translate the following Python program into MIPS
```python
if i == j:
k = 1
else:
k = 2
print("The value of k is",k)
```
## Set on Less Than investigation
Before executing: guess what you think `$t0`-`$t6` will be
Execute it: were you right?
What do `sle` and `sgt` mean? What do they get translated into by the assemler?
```mips
.text
li $s1, 2
li $s2, 2
li $s3, 3
#slt: "set on less than"
slt $t0, $s2, $s3
slt $t1, $s1, $s2
slt $t2, $s3, $s2
slti $t3, $s3, 10
#psuedoinstructions
sle $t4, $s1, $s3
sle $t5, $s1, $s2
sgt $t6, $s3, $s2
```
## Exercise
- Translate the following Python program into MIPS
- This is the same as your previous exercise, except with `i < j` instead of `i == j`
```python
if i < j:
k = 1
else:
k = 2
print("The value of k is",k)
```
## Compiling a `while` Statement
```python
i = 1
while i != 10:
print(i)
i += 1
```
---
```mips
.text
li $s0, 1
li $t0, 10
start_loop:
beq $s0, $t0, done
li $v0, 1 #print integer - no newline after!
add $a0, $s0, $zero #copy $s0 into $a0
syscall
addi $s0, $s0, 1
b start_loop
done:
```
## Exercise
- Translate this into MIPS
- Hint: can you use `slt` here?
```python
sum = 0
i = 0
while i < 10:
sum = sum + i
i += 1
print(sum)
```
## Assignment
- [Assignment 2](../../assignments/assignment-2/)
- Translate a Python program that has both an if statement and a loop