137x Filetype PDF File size 0.53 MB Source: www.whec.edin.sch.uk
- Book 2 - Writing Python Programs Level 4 Computing Science Contents 2 Writing Computer Programs 4 1. Calorie Counter 5 2. Garden Centre 12 3. Calorie Reward 15 4. National 4 – Programming Task 1 17 5. Average Calories 18 6. Average Solar Payment 21 7. National 4 – Programming Task 2 23 8. Tuck shop 24 9. Dental Fillings 28 10. National 4 – Programming Task 3 30 2 Book 2 – Writing Python Programs for Level 4 Computing Science 2 Writing Computer Programs Now that you have played with the programming building blocks in Python, it is time to learn how to put them together to make full computer programs. Different programs are made by simply putting the blocks together in different ways – much as you can make many different models out of one basic set of Lego™ building blocks. You will only be expected to write short programs as this stage. There is a lot to remember from Book 1 – Playing with Python. To help you, your teacher should issue you with a Python Crib Sheet. This summarises all of the Python commands that you learned about in Book 1. © E. Forrester, Distributed by AOK Learning Ltd 3 1. Calorie Counter Every new program starts with an idea. That idea is turned into a program statement – simply a sentence or two stating what the program is expected to do. In these notes the ideas and program statements have been made for you. Write a Calorie Counter program which… ◆ will ask for the number of Calories in porridge, toast, marmalade and coffee ◆ calculates total number of Calories consumed. ◆ displays this total number As a programmer, you first task is to analyse this program statement. The programmer needs to identify the action verbs, which indicate actions to be taken and nouns, which indicate possible variables. I have used a double line to underline the verbs and a single line to underline the nouns. ◆ will ask for the number Calories in porridge, toast, marmalade and coffee ◆ Calculates the total number of Calories consumed. ◆ Display this total number From here you can rewrite the task using the verbs and nouns, breaking it up even further into separate short sentences 4 Book 2 – Writing Python Programs for Level 4 Computing Science
no reviews yet
Please Login to review.