Do me a **favor**, take a few seconds to have a look at my last project.

Thank you, **Lulu**

The following python program computes and prints all the positive factors of a given input number.

```
# This function returns a list containing all the factors of a ginven parameters n
def getFactors(n):
# Create an empty list for factors
factors=[];
# Loop over all factors
for i in range(1, n + 1):
if n % i == 0:
factors.append(i)
# Return the list of factors
return factors
# Call the function with a given value
print (getFactors(256))
```

Here is how the above program works:

- we define a function
`getFactors()`

which takes a number as input and returns a list of factors; - this function initially creates an empty list;
- the function then iterates through number 1 to n using the built-in function
`range()`

; - if the reminder is 0, we know that the number is a factor of input number and hence we add it to the factors list;
- finally the factors list is returned.

`[1, 2, 4, 8, 16, 32, 64, 128, 256]`

It becomes easy to test if a given integer is a prime number:

```
if len(getFactors(42))==2:
print ('Prime number')
else:
print ('Not a prime number')
```

- Copy lists in Python
- Count list elements in Python
- Create lists in Python
- Delete lists in Python
- Get list elements in Python
- Insert, append, extend and concatanate lists in Python
- Iterate over lists in Python
- Remove an element from a list in Python
- Reverse lists in Python
- Find elements in lists in Python
- Slice lists in Python

Last update : 04/13/2019