Task 2 – Loops and Lists

The use of loops in any programming language improves how efficient the program is and reduces the length of the program. Understanding loops is essential in being able to program and creating useful programs/games. The following information will show what loops are and the different types of loops, why we use them and how to include them within your program.

When using loops in Python, I think that it is handy to know about Lists. So please work through the following section of codecademy:

Please read sections 7.1 to 7.5 from the following link: Lists

– Unit 5: Lists and Dictionaries (only complete the subsection: Lists)
NOTE: we will not be covering functions.

Please read sections 4.1 and 4.2 from the following link: For loops

Now complete the following sections on Codecademy:
– Unit 8: Loops (only complete the subsection: For Loops).

You have now dealt with For Loops and should understand that they are referred to as ‘unconditional loops’. You are now going to look at While Loops.

Please read sections 4.3 and 4.4 from the following link: While loops

Now complete the following sections on Codecademy:
– Unit 8: Loops (only complete the subsection: While Loops).

Display a given message

Ask the user for a message and then display the message four times

Password Generator

You program should generate three random passwords. They should be saved in a list and then displayed to the user.
Note: The code for creating a random password can seen below:

>>> import string
>>> import random
>>> def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
...    return ''.join(random.choice(chars) for _ in range(size))
...