## 1 Homework

### Homework 1 - Programming Basics

• During week 1 you have played a text based game and had a look at the Python code.
• During week 2, you have learned and practiced using while loops.
• For this assignment
1. Write lines of code for the following:
1. ask user to input a number and store the input in a variable
2. convert the input number to an integer
3. if the number is greater or equal to 10, output "It's double digit number at least", else output "It's a small number"
2. Explain how this line of code works:
```random.randrange(0,10)
```
3. The follow code is supposed to output numbers from 0 to 9. But it has an error in it. Please identify the error.
```while x < 10:
x = 0
print (x)
x += 1
```

### Homework 2 - The range command

 ```1 2``` ```for I in range(5): print("Welcome to the range") ```
• The above code is a for loop - that is, the command indented underneath the `for i in range(5)` will be repeated. In this case, the `Welcome to the range` will be printed 5 times. Why?
• It is becasue the number of times a loop repeats is specified by the number given in the range(5).
• Range command works like this:
1. `range(upToNumber)` - it produce a sequence of numbers from 0 up to BUT NOT equal to the upToNumber. For example, range(5) will produce: `0,1,2,3,4`, therefore, there are 5 numbers, for each number the loop going through, it prints out "Welcome to the range".
2. `range(startNumber, upToNumber)` - it produces a sequence of numbers from startNumber to BUT NOT equal to the upToNumber. For example, range(3,8) will produce: `3,4,5,6,7`
3. `range(startNumber, upToNumber, increaseBy)`- it produces a sequence of numbers from startNumber to BUT NOT equal to the upToNumber, each time the next number increase by the number specified by `increaseBy`. For example, range(2,10,2) will produce: `2,4,6,8`.
 ```1 2``` ```for i in range(10, 20, 2): print(i) ```
 ```1 2``` ```for i in range(100, 40, -5): print(i) ```