1 / 12

CS001 Introduction to Programming Day 3

CS001 Introduction to Programming Day 3. Sujana Jyothi ( sujana @cs.nuim.ie ). What have we learnt so far?. Program – sequence of steps Terms learnt : source code, compiler, statement, data-type, variable, constant. Sequence, Decision. Resources. Resources

kmoyer
Download Presentation

CS001 Introduction to Programming Day 3

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. CS001Introduction to ProgrammingDay 3 Sujana Jyothi (sujana@cs.nuim.ie)

  2. What have we learnt so far? • Program – sequence of steps • Terms learnt: source code, compiler, statement, data-type, variable, constant. • Sequence, Decision

  3. Resources • Resources • Use the material from my website. http://www.cs.may.ie/~Sujana/CS001.html • Save your work • on your flash drive • or email it to yourself

  4. ALGORITHM An algorithm is a systematic list of instructions for accomplishing some task, and the task can be anything that has a recognizable end-point (or result). Often some of the specific steps in the procedure are to be repeated until the task is done. Imagine you have a random, unsorted list of numbers. Our goal is to find the highest number in this list. 1. Pretend the first number in the list is the largest number. 2. Look at the next number, and compare it with this largest number 3. Only if this next number is larger, then keep that as the new largest number 4. Repeat steps 2 and 3 until you have gone through the whole list.

  5. ALGORITHM EXAMPLE A farmer has to take three items, a dog, a goat and a cabbage, across a river. He has a boat but it can take two objects at once, in other words, the farmer and one other item only. If the dog and the goat are left together, the dog will bite the goat. If the goat and the cabbage are left together the goat will eat the cabbage. WRITE AN ALGORITHM TO TELL THE FARMER HOW TO GET THE THREE ITEMS ACROSS THE RIVER.

  6. Learn Programming Through Scratch Scratch -> "new programming language that lets you create your own animations, games, and interactive art."

  7. Statement in Scratch Called BLOCKS in SPRITE Tells the computer to do something Instructs a sprite to say something Instructs a sprite to go to some location

  8. Logic Structures • Sequence • Decision / Selection if statement • Looping / Iteration/ Repetition for statement while statement

  9. Boolean Expression • Boolean expression is an expression that is either true or false. TRUE when the mouse is down FALSE when the mouse is not down TRUE when ??????? FALSE when ????????

  10. Decision if statement Instruct a sprite to say hello only if, the user has depressed the mouse button

  11. Decision If - else statement Instruct a sprite to say hello or goodbye, depending on whether the user has pressed the mouse button or not.

  12. Looping / Iteration/ Repetition

More Related