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


Task 1 – Becoming familiar and a bit more!

In order to complete these series of mini-tasks you will first need to complete sections 1, 2, 3, 4 and 5.

Read the following links too:
Quiz games and if statements.

1: Play withing Strings.
– The user of your program should enter their first name, surname and date of birth.
– The program should then display the length of each piece of data and convert it to uppercase and lowercase.

2: You must create a speed, distance and time calculator.

Help on creating a calculator can be found here.

– The user must first choose whether they want to calculate S, D or T.
– The user should then be prompted to enter in the relevant information for the chosen calculation.
– The program should then calculate the answer and display an appropriate message. You must use the technique from ‘Strings and Console Ouput – sub-section 15’.
– Your program should be timestamped (dd/mm/yyyy : hh-mm-ss).

3. Complete the above problem in Scratch!!!

3: A Mathematical Calculator (CHALLENGE)
 – You must create a calculator that can perform the basic operations, powers and roots (square) and percentages.

Code Academy

We will be using Code Academy to help us learn how to use Python.

It works by you completing programs via a web browser and the system will provide instant feedback on your solution. Remember, keep your wits about you as some of th problems and concepts can be quite complex.

Click on the link below to access the Code Academy:


As a quick reference you can also visit the following site:


Getting Started – Python

At Dunblane High School our main programming language will be Python and this will be used at National 5 and Higher.

A Bit of History
Python is a general-purpose interpreted, interactive, object-oriented and high-level programming language. Python was created by Guido van Rossum in the late eighties and early nineties. Like Perl, Python source code is also now available under the GNU General Public License (GPL). Although, Python is quite an old programming language it is making a comeback through its inclusion within the Raspberry Pi software bundle. Development is also in place to convert programs written in Python to apps for Android.

HTML and CSS Part 1

Introduction to HTML and CSS:




Linking your account

At code academy you are given the option to link your account to google, facebook and yahoo. During your National 5 course, it is preferred that you do not link to any social networking account. After the course has been completed and you have sat exam then by all means link your account.