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.
Your task is to produce a program to print the words to the song Ten Green Bottles. Your program should:
be efficient and use a loop - it shouldn't just PRINT the whole song
include the correct number of bottles at each stage, counting down from 10 to 1
consider how to lay out the words to make the song clear and easy to read
You can use any other programming tricks you've learnt to improve the program. If you've been reading ahead, you could use a list or tuple to display the number in words instead of digits - e.g. ten green bottles instead of 10 green bottles.