Introduction to Computer Science

Slides:



Advertisements
Similar presentations
Computer Science 101 While Statement. Iteration: The While-Statement The syntax for the While- Statement is while : The syntax for the While- Statement.
Advertisements

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Python Programming: An Introduction to Computer Science
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Chapter 2 Writing Simple Programs
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Geography 465 Assignments, Conditionals, and Loops.
Structure of program You must start with a module import# You must then encapsulate any while loop in a main function at the start of the program Then.
© 1999, by Que Education and Training, Chapter 7, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 2.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Python Mini-Course University of Oklahoma Department of Psychology Day 4 – Lesson 13 Case study: Word play 05/02/09 Python Mini-Course: Day 4 – Lesson.
For loops in programming Assumes you have seen assignment statements and print statements.
INTRODUCTION SELECTION STATEMENTS -Control Expression -Single/Compound Clauses -Dangling Else MUTLIPLE SELECTION CONSTRUCTS -C/Java Switch -C# Switch -Ada.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 2.
Introduction Copyright © Software Carpentry This work is licensed under the Creative Commons Attribution License See
2016 N5 Prelim Revision. HTML Absolute/Relative addressing in HTML.
Compsci 101.2, Fall Plan for WEFWOO l Review for exam, studying and practicing for exams and APTs in Compsci 101  Why memorization doesn't help.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
LOOPS CHAPTER Topics  Four Types of Loops –while –do…while –for –foreach  Jump Statements in Loops –break –continue 2.
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.
Loop Structures and Booleans Zelle - Chapter 8 Charles Severance - Textbook: Python Programming: An Introduction to Computer Science,
An Introduction to the Java Language App Design Flat Rock Community Schools Introductory Java Programming.
Lecture 4 CS140 Dick Steflik. Reading Keyboard Input Import java.util.Scanner – A simple text scanner which can parse primitive types and strings using.
Chapter 2 Writing Simple Programs
Computer Programming Fundamentals
Data Types and Structures
Python: Control Structures
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Computer Science Faculty
Topics discussed in this section:
Lecture 2: Introduction to Algorithms
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
File Handling Programming Guides.
Introduction to Processing Digital Sounds part 2
Introduction to pseudocode
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Loop Structures and Booleans Zelle - Chapter 8
Chapter 1: Introduction
Chapter (3) - Looping Questions.
Higher Computing Using Loops.
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Lists in Python Outputting lists.
While loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
Elements of a Python Program
Chapter 4 Loops Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Review for Test1.
Java Programming: Chapter 9: Recursion Second Edition
CHAPTER 6: Control Flow Tools (for and while loops)
Intro to Computer Science Loops
CHAPTER 21 LOOPS 1.
Introduction to Computer Science
Introduction to Computer Science
Introduction to Computer Science
Introduction to Computer Science
Statements in C Programming
Chopin’s Nocturne.
Welcome back! October 11, 2018.
Repetition Structures
Iteration – While Loops
Introduction to Computer Science
Introduction to Computer Science
Introduction to Python
Introduction to Computer Science
Computer Programming Tutorial
Presentation transcript:

Introduction to Computer Science Programming with Python

Loops & Iteration Chapter 5

Definite Loops – for loops For loops are easier to validate They are used to a fixed start and end Example, to go through a list, all the lines in a file, or all the characters in a string

Simple for Loop The following loop start from 0 to 10 (it doesn’t execute 10) and print i (counter)

A Simple Definite Loop – the Pythonic way

A Definite Loop with Strings

A Simple Definite Loop – the Pythonic way

For Loops in Most Programming Languages The below example shows a for loop in Java that shows the initialization of the counter that start from 0 to 10, and it increments i (counter) by 1 every iteration. Tip, ++ in most programming languages means +1, but not in Python