# Homework tasks

## 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
- Write lines of code for the following:
- ask user to input a number and store the input in a variable
- convert the input number to an integer
- if the number is greater or equal to 10, output "It's double digit number at least", else output "It's a small number"

- Explain how this line of code works:
random.randrange(0,10)

- The follow code is supposed to output numbers from 0 to 9. But it has an error in it. Please identify the error.

- Write lines of code for the following:

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:
`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".`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`

`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`

.

- Your homework:
- What numbers are produced in this loop:
1 2

for i in range(10, 20, 2): print(i)

- What numbers are produced in this loop:
1 2

for i in range(100, 40, -5): print(i)

- write a for loop that will print out all positive whole numbers (integers) up to 100 that are divisible by 5.

- What numbers are produced in this loop:

### Homework 3 - Literacy Task

- coming soon