For Loops Pages 92 - 93.

Slides:



Advertisements
Similar presentations
Switch code for Lab 4.2 switch (input) { /* input is a variable that we will test. */ case 'M': printf("The prefix is equal to 1E6.\n"); break; case 'k':
Advertisements

Iteration While / until/ for loop. Iteration: while/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initalise.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 2 Microcomputer Systems Design (Embedded Systems)
Copyright © 2014 Dr. James D. Palmer; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Nested Loops. Nesting Control Structures One if statement inside another one An if statement inside a loop A loop inside an if statement Control structures.
Lecture 13 – range function, for…in loops COMPSCI 1 1 Principles of Programming.
Control Structures FOR Statement Looping.
Ch. 10 For Statement Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2012.
Advanced Program Design. Review  Step 1: Problem analysis and specification –Specification description of the problem’s inputs and output –Analysis generalize.
Today’s Announcements Assignment 8 is due Project 2 is due 7/27/04 We will be skipping chapter 22 Test 3 (chapters 18-21) will be on 7/29/04 Tip of the.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
COMP Loop Statements Yi Hong May 21, 2015.
Source Page US:official&tbm=isch&tbnid=Mli6kxZ3HfiCRM:&imgrefurl=
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
Introduction to Computing Using Python Repetition: the for loop  Execution control structures  for loop – iterating over a sequence  range() function.
Loops (While and For) CSE 1310 – Introduction to Computers and Programming 1.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
Repetition Looping. Types for while do..while for The for loop allows you to iterate through a variable for a specific range of values. You must supply.
 See pages 65 – 67 in your book  While loops are all around us ◦ Shampoo  Rinse, Lather, Repeat  While (Condition Is True) : ◦ Execute a block of.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Путешествуй со мной и узнаешь, где я сегодня побывал.
Follow up from lab See Magic8Ball.java Issues that you ran into.
Trace Tables In today’s lesson we will look at:
Python Loops and Iteration
Functions f(x)=2x-7 g(x)=x+12 Bob Greer.
Think What will be the output?
Algebra 1 Section 1.7 Identify functions and their parts
Repetition: the for loop
ASSIGNMENT NO.-2.
Counted Loops.
Repeating code We could repeat code we need more than once: i = 1 print (i) i += 1 print (i) #… stop when i == 9 But each line means an extra line we might.
Relations and Functions Pages
Page 1. Page 2 Page 3 Page 4 Page 5 Page 6 Page 7.
Ruth Anderson UW CSE 160 Spring 2018
Arrays, For loop While loop Do while loop
Introduction to pseudocode
Unary Operators ++ and --
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Looping and Random Numbers
CEV208 Computer Programming
Topics Introduction to Repetition Structures
Looping Topic 4.
Suggested Layout ** Designed to be printed on white A3 paper.
Introduction to Repetition Structures
5.2 Relations and Functions
Page 18 Rule: Area Formula: L x W  Input x Input  (Input) = Output
Synchronous Counters 4: State Machine Counting
For Loops (Iteration 1) Programming Guides.
Examples Example Problems, their Algorithms, and their C Source Code.
Counter Integrated Circuits (I.C.s)
15-110: Principles of Computing
CHAPTER 6: Control Flow Tools (for and while loops)
CS 1111 Introduction to Programming Spring 2019
For loops Taken from notes by Dr. Neil Moore
Topics Introduction to Repetition Structures
Introduction to Computer Science
Repetition: the for loop
Input a number and print its table, using FOR loop.
Introduction to Computer Science
Properties of Functions
7.4 Slope Objectives: To count slope To use slope formula.
MIS 3200 – Unit 5.1 Iteration (looping) Working with List Items
Relations/Sequences Objective: Students will learn how to identify if a relation is a function. They will also be able to create a variable expression.
Incremental Programming
Lec 21 More Fun with Arrays: For Loops
GCSE Computing.
Control flow: Loops UW CSE 160.
Tuple.
Presentation transcript:

For Loops Pages 92 - 93

Anatomy Of A ‘For Loop’ Iterates through a sequence Needs a counter variable is assigned a number Counter variable changes by the same amount on each iteration of the loop The range() function allows you to count in all kinds of ways It is traditional to use “i” or “j” as counters in a for loop, even though most of the time you should use a more descriptive variable name

print(“Output:”) for i in range(5) : print(i) Output: 1 2 3 4 print(“Output:”) for i in range(2, 6) : print(i) Output: 2 3 4 5 print(“Output:”) for i in range(0, 25, 5) print(i) Output: 5 15 20 print(“Output:”) for i in range(5, 0, -1) : print(i) Output: 5 4 3 2 1