Year 5 Exam  >  Year 5 Notes  >  Year 5 Computing  >  Repetition and selection

Repetition and selection | Year 5 Computing PDF Download

Understanding Computer Programs

  • Computers and computer-controlled devices are integral to every aspect of our lives.
  • They are exceptionally rapid, precise, and adept at managing vast amounts of data. Additionally, they can multitask effectively.
  • Before they begin tasks, we must provide instructions through a computer program.
  • These instructions are written in a coding language that computers comprehend.
  • It's crucial to organize our instructions systematically to ensure efficient execution by the computer.

Repeat, repeat, repeat

  • In programming, one important way we organize instructions is with a "REPEAT" command.
  • Consider the task of photocopying a document 30 times. If we had to enter each copy command individually, it would be time-consuming.
  • Instead, we can specify in the photocopier settings that we want to print 30 copies. This instruction directs the printing program to repeat the copying process 30 times.
  • The "REPEAT" instruction is placed at the beginning of the program. This type of repeat command is known as a fixed loop because the number of repetitions is predetermined.
  • An example program might look like this:
    Repetition and selection | Year 5 Computing

Repeating until something happens

  • Sometimes, we may not know in advance how many times we need to repeat an action or task. In such cases, we can use a "UNTIL" command.
  • For example, when washing dishes, we don't scrub the sponge across a plate a fixed number of times. Instead, we wipe the sponge UNTIL the plate is clean. We continuously check the plate for food residue, and when we determine it's clean, we stop wiping.
  • This approach allows us to repeat an action until a specific condition is met, making our processes more adaptable and responsive to changing conditions.
    Repetition and selection | Year 5 Computing

Question for Repetition and selection
Try yourself:
Which command is used in programming to repeat an action a predetermined number of times?
View Solution

Programming with REPEAT UNTIL

  • Using the REPEAT UNTIL command in a computer program involves instructing the program to repeat an action until a specific condition is met.
  • For example, imagine we want a robot in a game to walk across the screen and halt at the screen's edge.
  • The challenge is that we don't know the exact size of the screen it will traverse.
  • To address this, we can utilize the REPEAT UNTIL command to make the robot stop when it reaches the screen's edge, regardless of its size.
  • However, a new challenge arises: how will the program recognize when the robot reaches the edge? This is a problem that needs to be solved in the programming logic.

Repetition and selection | Year 5 Computing

Asking a Question

  • A problem-solving approach involves creating a precise set of ordered rules or instructions, known as an algorithm, which can be followed by humans or computers to accomplish a task.
  • Algorithms are essential in guiding the steps needed to reach a solution.
  • When programming a robot to navigate a screen, it is crucial for the program to determine if the robot has reached the screen's edge.
  • The program poses the question: "Have you reached the edge of the screen yet?"
    • If the answer is YES, the robot will halt; if NO, it will continue moving forward while monitoring the screen's edge.
  • Conditional Loop
    • A conditional loop contains a condition that must be satisfied for the loop to terminate.
    • It prompts the program to continuously check conditions until a specific criterion is met.
    • This type of loop is commonly referred to as a conditional loop due to its dependence on meeting specific conditions to continue or halt.

Repetition and selection | Year 5 Computing

Selection - what should I do?

  • From the example of the conditional loop above, it's evident that incorporating questions into a computer program can assist in solving complex problems.
  • Questions in computer programs enable the computer to make decisions or selections.
  • This capability allows programs to handle diverse situations and challenges by executing different sections of code or even separate programs based on various conditions.
  • The use of selection in computer programs enhances their flexibility and enables them to effectively manage dynamic scenarios such as traffic, weather conditions, and everyday life challenges.

Making choices

  • You are preparing for a day out in the park and are unsure whether to bring your umbrella. Your decision depends on the weather conditions.
  • You glance out of the window quickly. If it is raining, you decide to take an umbrella. If it is not raining, you opt to leave it at home.
  • These decisions are a regular part of daily life, where we assess conditions and make choices accordingly.
  • We can create a flowchart to illustrate this process:
    Repetition and selection | Year 5 Computing

Programming a computer to make a selection

  • Computer programmers refer to this method of organizing instructions in a program as selection.
  • In programming, selection involves choosing an answer or action from multiple possibilities.
  • Programmers often use commands like IF, THEN, and ELSE when writing programs that involve selection.
    • ELSE in coding languages denotes "otherwise" or "if not," providing an alternative action if the condition specified in the IF statement is not met.
    • Using IF and ELSE is typically more efficient than using YES and NO.
  • For instance, if we were to program a robot to go to the park, the program might look like this:

Repetition and selection | Year 5 Computing

Question for Repetition and selection
Try yourself:
What programming construct involves repeating an action until a specific condition is met?
View Solution

The document Repetition and selection | Year 5 Computing is a part of the Year 5 Course Year 5 Computing.
All you need of Year 5 at this link: Year 5
19 videos|26 docs|3 tests

Top Courses for Year 5

FAQs on Repetition and selection - Year 5 Computing

1. What are the requirements to pass the UK Schools exam?
Ans. To pass the UK Schools exam, students typically need to achieve a certain score or grade in each subject that they are being tested on. This can vary depending on the specific exam board and the level of the exam.
2. How can students prepare effectively for the UK Schools exam?
Ans. Students can prepare for the UK Schools exam by studying the material covered in class, practicing past exam papers, and seeking help from teachers or tutors if needed. It's also important to manage time effectively and stay organized during the revision period.
3. Are there any resources available to help students study for the UK Schools exam?
Ans. Yes, there are a variety of resources available to help students study for the UK Schools exam. This can include textbooks, online resources, study guides, and revision courses. Many schools also offer extra support and resources to help students prepare for exams.
4. What should students expect on the day of the UK Schools exam?
Ans. On the day of the UK Schools exam, students can expect to be given specific instructions on how to complete the exam, including the timing of each section and any materials they are allowed to use. It's important to arrive early, bring all necessary equipment, and stay calm and focused during the exam.
5. How are UK Schools exams graded and when can students expect to receive their results?
Ans. UK Schools exams are typically graded on a scale from A* to U, with A* being the highest grade. The exact grading system can vary depending on the exam board and level of the exam. Students can usually expect to receive their exam results a few weeks after completing the exam.
19 videos|26 docs|3 tests
Download as PDF
Explore Courses for Year 5 exam

Top Courses for Year 5

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

practice quizzes

,

Repetition and selection | Year 5 Computing

,

Repetition and selection | Year 5 Computing

,

Viva Questions

,

Repetition and selection | Year 5 Computing

,

Sample Paper

,

shortcuts and tricks

,

pdf

,

ppt

,

Important questions

,

Previous Year Questions with Solutions

,

video lectures

,

Free

,

Extra Questions

,

past year papers

,

MCQs

,

mock tests for examination

,

Exam

,

Summary

,

study material

,

Semester Notes

,

Objective type Questions

;