﻿

# Ten Green Bottles

In this task, you're going to use your programming skills to print the words to the children's song Ten Green Bottles. If you missed the first assignment, click here for instructions on how to install Python. If you are unable to install Python then you can use replit.com to run your programs on-line.

## Commands

Here is a reminder of the commands you might need for this assignment. As the course progresses, you will get fewer of these reminders.

• print() - text needs to be put in speech marks, e.g. print("Hello"), numbers and variables don't, e.g. print(10) or print(A). You can use the + symbol to concatenate (join) text, but remember that Python is typed, so you will need to cast numbers to combine them with text - e.g print("My age is "+str(21)).
• input - used to ask the user for a number, e.g. age = input("How old are you? ") will ask the question and store the answer in a number variable called age. Note that the result will be stored as a string unless you cast it to an integer using int().
• for - repeats a section of your program a number of times - e.g. for n in range(10) will repeat 10 times, counting with n from 0 to 9. If you don't want to count in 1s, you can add extra arguments, e.g. for n in range(5, 100, 5) will count from 5 to 95 in 5s, and for n in range (10, 0, -1) will count from 10 down to 1. You don't need to use n - it's just a programmers' habit, like using x in algebra; any valid variable name will do.
• Indentation is used to indicate which parts of your program are repeated, e.g.

for n in range(10):
print("This will be printed ten times.")
print("This will be printed once.")

The following program, for example, will print the numbers from 10 to 100, going up in 10s:

for n in range(10,101,10):
print(n)

• Comments - these are lines in your program that don't do anything. They are like labels and are usually use to remind you (or someone else looking at your program) what it does. Any line that begins with a hash symbol is treated as a comment, e.g. # My First Program.

If you can't remember how the song goes, or would like to read more about it, have a look at the Ten Green Bottles Wikipedia page.