You should be able to:
To generate numbers randomly in Python we need to import the library function known as random.
import random
We can then use this function to randomise.
Examples of this could be:
Random Choice
import random
myArray = ["ONE","TWO","THREE"]
print (random.choice(myArray))
This just picks a random item from an array.
Random Integer
import random
print (random.randint(1,20))
This will pick a random integer between 1 and 20.
Random Integer from a Range
import random
print (random.randrange(1,20))
This will pick a random integer between 1 and 20 but will not include the number 20.
Shuffle
To use shuffle you also need to import shuffle from random
.
import random
from random import shuffle
myArray = ["HELLO","GOODBYE","NICE","HOW ARE YOU"]
shuffle(myArray)
print(myArray)
Password Generator Machine
Create an app that creates a random password when a user first creates an account. The random password should:
Extending the Program - Extra Mile Task
The user should have the option to:
SOURCE RECOGNITION - PLEASE NOTE: The examination examples used in these walking talking mocks are samples from AQA from their non-confidential section of the public site. They also contain questions designed by TeachIT for AQA as part of the publicly available lesson materials.