1 / 19

Computer Programming

Computer Programming. Task 5. Story time. Why program?. Click for an Idea!. Task Aims:. T1 : Writing out text using 3x “ to write on multiple lines T2 : Using elif to extend conditional statement T3 : Understanding different error messages when debugging

marlow
Download Presentation

Computer Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Programming Task 5 Story time

  2. Why program? Click for an Idea!

  3. Task Aims: T1 : Writing out text using 3x “ to write on multiple lines T2 : Using elif to extend conditional statement T3 : Understanding different error messages when debugging T4 : Importing the Time module T5 : Making your own function by defining with def T6 : Flowchart of your adventure so far T7 : Adding to the adventure T8 : Evaluating your progress

  4. Story time What story can you tell?It should be creatively writtenSpelling, grammar & punctuation will bea strong part of this assessment!

  5. T1 Adventure Game Setting the scene: Where will it take place? • Task 1 • Open Python and create a beginning for your Adventure: • Where will it take place? • When will it Happen? • Who will be the hero • What will be the Drama • Will there be mild peril? • Q:What does ””” do to the string?

  6. Learning Objectives Identify... ...that if and else are limited to only two outcomes Describe... ..how elif can be used to extend options Explain... ...in your code how if , elif and else can work Apply... ...a range of conditional statements Link... ...your python code into a well written adventure

  7. Last time, you entered in this program called MathsQuiz.py But what if you want more than one option?

  8. …ELIF It allows you to extend your choices to more than just the two available with if else. Now you can have:if ...junk Food..."mmm keep it coming“ elif ...Doughnuts..."argggdrooool"elif...Sweets..."Its not doughnuts but mmmm"elif...Duff..."Mhmmmmm"elif (as many as you need - which for Homer is a lot!) else..."I can't eat this!!!"

  9. T2 If…elif…else • TASK 2: • Copy out the code exactly as you see it, change the content to fit your story but watch out for these mistakes: • Define the Choice variable at the start • Use == and : on each if, elif and else statement • Only 1 indentation for each of the print functions under a conditional statement

  10. Code close up The variable we will use is called ‘choice’ define this first at the beginning Indentation shows “ownership” so the print function belong to the elif statement

  11. T3 Debugging? There are 3 main errors made by programmers (that is us!) Syntax Errors – e.g.. silly typing errors Run-time Errors – e.g.. it may run but crashes at some point Logical Errors – e.g.. getting the code to run but it does something different TASK 3: Run you program, If it comes up with an error message read it carefully – • Is it telling you its a EOL ( end of line) Syntax error? Perhaps you forgot a colon at the end of a line of code? This is probably the most common error you will get: a Trace back error message- its saying that the variable is not defined – did you assign choice=input properly?

  12. Sign up at Codecademy and start this python course: http://www.codecademy.com/courses/python-beginner-sRXwR/0/1 This will be YOUR way of extending YOUR learning either in lesson or at home!

  13. Hardware & Software >>>What is the difference between Software & Hardware? >>>Why do we have to program computers? Click

  14. T4 Importing Time? TASKS: • Keep the structure the same • Change the information to your own story • What does the time import do? • What does the triple “”” do? Why is this useful? • Why does work the way it does? You have used the import feature of python with the Turtle work: it’s a library. A library or module always gets called at the start of your code

  15. T5 Making your own Functions TASK 5 Add this code to your Adventure Game:

  16. Algorithms as Flowcharts

  17. T6 Flowchart of Adventure TASK 6: Create a flow chart planning out the structure and decisions in your adventure T7 Extend your Code TASK 7: Where will your Adventure go? Use the skills learned to extend your Adventure T8 Evaluate your Program TASK 8: Print screen your code, print screen it running & evaluate the program. For maximum marks use technical terms, discuss the problems you encountered, solutions as well as the what went well & how you could improve it .

  18. 1. Random function 2. Lists / Arrays 3. Functions Extension work

More Related