Example Programs.

Slides:



Advertisements
Similar presentations
Dynamic Demand Inventory Control System By Supamas Viriyanusorn Jitrayut Junnapart.
Advertisements

CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
VB PROJECT “PROJECT SAMPLES”. For Next Loops Design a VB program that displays in a picture box the first N multiples of an input integer Input 3 exam.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
JavaScript with Input & Output Step 1: Use tags JavaScript Template.
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
The fourth programming assignment J.-F. Pâris Fall 2014.
Adapted from slides by Marie desJardins
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
More While Loop Examples CS303E: Elements of Computers and Programming.
Friends = ['Tom', 'Sue', 'Danny', 'Joe', 'Mary'] Index positions >>>Friends[2] Danny >>>Friends[2:4] Danny, Joe >>>Friends[-4] Sue Use your PYTHON.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Count and add list of numbers From user input and from file.
Designing While Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
File Handling in QBASIC
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Count Controlled Loops (Nested) Ain’t no sunshine when she’s gone …
Creating a mystic meg program A simple program asking the user questions and using their answers to build up a fortune telling in a list.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
1 Class Chapter Objectives Use a while loop to repeat a series of statements Get data from user through an input dialog box Add error checking.
Lecture 7: Menus and getting input. switch Multiple-selection Statement switch Useful when a variable or expression is tested for all the values it can.
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Strings … operators Up to now, strings were limited to input and output and rarely used as a variable. A string is a sequence of characters or a sequence.
Functions CMSC 201 – Lab 5. Overview Objectives for today's lab:  Practice breaking down a program into multiple functions  Practice writing function.
Indistar® Beginning the Process: The first few steps.
7 - Programming 7J, K, L, M, N, O – Handling Data.
CSC111 Quick Revision.
while Repetition Structure
Chapter Topics 11.1 Introduction to Menu-Driven Programs
While Loops in Python.
Lecture 07 More Repetition Richard Gesick.
Logical Operators and While Loops
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Python I/O.
File Handling.
Lesson 09: Lists Topic: Introduction to Programming, Zybook Ch 8, P4E Ch 8. Slides on website.
int [] scores = new int [10];
IST256 : Applications Programming for Information Systems
Module 4 Loops.
Computer Science 2 Getting an unknown # of …. Into an array.
Remembering lists of values lists
Lesson 09: Lists Class Chat: Attendance: Participation
Text Analyzer BIS1523 – Lecture 14.
CS150 Introduction to Computer Science 1
Flowcharts and Pseudo Code
A LESSON IN LOOPING What is a loop?
Logical Operators and While Loops
Python Basics with Jupyter Notebook
Introduction to Programming with Python
More Trees 5/9/2-017 Be able to dry run a program that uses trees
Hint idea 2 Split into shorter tasks like this.
While Loops in Python.
File Handling.
GCSE Computing.
Presentation transcript:

Example Programs

Finding the average score in a list

Counting (Tally) items in a list

Finding Mobile Phone product details See speaker notes for code #this is a list that contains product informaton product = ["1262", "Cornflakes", "£1.40", "8743", "Weetabix", "£1.20", "9512", "Rice Krispies", "£1.32"] #stores whether the product has been found found= False #asks the user to enter a product code product_code=input("Enter the product to find: ") #a loop that will repeat for the length of the list for x in range(0,len(product)): #checks if the product code entered matches the current element of the list being checked if product[x] == product_code: #if it is it prints the name and cost print(product[x + 1]) print(product[x + 2]) #sets found to true as the product is found found = True #after the loop checks if the product was not found if found==False: #if it wasn't found it says product not found print("Product not found")

Update contact list See speaker notes for code #Create a new list inventory = ["torch","gold coin","key"] # for loop that outputs the current list print("Current Inventory") for x in range(len(inventory)): print(inventory[x]) #menu that gives the options of what can be done print("What would you like to do? ") print("1. Add an item to the inventory") print("2. Remove an item from the inventory") #gets the user to enter their menu choice option = input(">> ") #if the first option is selected if option == "1": #ask the user to input the item to add item = input("Enter the name of the item you want to add to the inventory: ") #use append to add it to the list inventory.append(item) #if the second option is selected elif option == "2": #ask the user to input the item to remove item = input("Enter the name of the item you want to remove from the inventory: ") #use remove to delete the item from the list inventory.remove(item) #for loop that will output the updated list print("Updated inventory list")