Friends = ['Tom', 'Sue', 'Danny', 'Joe', 'Mary'] Index positions 0 1 2 3 4 >>>Friends[2] Danny >>>Friends[2:4] Danny, Joe >>>Friends[-4] Sue Use your PYTHON.

Slides:



Advertisements
Similar presentations
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?
Advertisements

ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Stack-up Verification 2K Features :  Quick selection of Standard Parts via pull down menu lists.  Pop-ups prompt you to decide whether the extra washers.
COMPSCI 105 S Principles of Computer Science 13 Stacks.
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Main Index Contents 11 Main Index Contents Model for a Queue Model for a Queue The Queue The Queue ADTQueue ADT (3 slides) Queue ADT Radix Sort Radix Sort.
Programming with Collections Grouping & Looping - Collections and Iteration Week 7.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
CST JavaScript Validating Form Data with JavaScript.
Functions.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Ten String Manipulation and Menus.
Chapter 8: String Manipulation
Programming with Microsoft Visual Basic th Edition
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Noadswood Science,  To understand what strings are and how decisions are made Thursday, September 17, 2015.
Lists in Python.
Part 2. Searching Arrays Looking for a specific element in an array E.g., whether a certain score (85) is in a list of scores Linear search Binary search.
Chapter 17: Arrays Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Queues Chapter 3. Objectives Introduce the queue abstract data type. – Queue methods – FIFO structures Discuss inheritance in object oriented programming.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
6.3 List Boxes and Loops Some Properties, Methods, and Events of List Boxes List Boxes Populated with Strings List Boxes Populated with Numbers Searching.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
From the initial (HINARI) PubMed page, we will run the HIV and pregnancy search and then apply various Filters. Note the to Advanced search and Help options.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Chapter 8: Manipulating Strings
Microsoft ® Office Excel 2003 Training Using XML in Excel SynAppSys Educational Services presents:
FT228/3 Web Development Error processing. Introduction READ Chapter 9 of Java Server Pages from O’reilly 2 nd Edition Need to be able to 1) Diagnose and.
Chapter 3: Branching and Program Flow CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Lists CS303E: Elements of Computers and Programming.
Data Structures & Algorithms
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
Headings are defined with the to tags. defines the largest heading. defines the smallest heading. Note: Browsers automatically add an empty line before.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 4 Karsten Hokamp, PhD Genetics TCD, 01/12/2015.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Arrays. Array: Sequence of values of the same type Construct array: Store in variable of type double[ ] new double[10] double[] data = new double[10];
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
Python Programing: An Introduction to Computer Science
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
Part A. Remote Viewing IP Surveillance Camera Application Guide.
Control Structures WHILE Statement Looping. S E Q C E N U E REPITITION …a step or sequence of steps that are repeated until some condition is satisfied.
Magic 8 ball. "Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question.
Lists/Dictionaries. What we are covering Data structure basics Lists Dictionaries Json.
11 March 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
CMSC201 Computer Science I for Majors Lecture 08 – Lists
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
More on Lists.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Week 8 - Programming II Today – more features: Loop control
Example Programs.
CIS16 Application Development and Programming using Visual Basic.net
Data Structures – 1D Lists
4. sequence data type Rocky K. C. Chang 16 September 2018
Lists in Python Creating lists.
Adding a Class (Classes are the third level of your organization’s offerings hierarchy: Program > Category > Class > Session) 1.) Enrichment tab > Class.
Lesson 09: Lists Class Chat: Attendance: Participation
Principles of Computing – UFCFA3-30-1
Spreadsheets, Modelling & Databases
Topics Sequences Lists Copying Lists Processing Lists
Chapter 5 Stack (part 1).
Principles of Computing – UFCFA3-30-1
Adding a Care Class (Classes are the third level of your organization’s offerings hierarchy: Program > Category > Class > Session) 1.) Enrichment tab >
File Handling.
Executive Reports, Instructions and Documentation
Introduction to Computer Science
Presentation transcript:

friends = ['Tom', 'Sue', 'Danny', 'Joe', 'Mary'] Index positions >>>Friends[2] Danny >>>Friends[2:4] Danny, Joe >>>Friends[-4] Sue Use your PYTHON textbook to help you today. Chapter 6 ‘Lists’ (page 67)

append adds an element onto the end of a list. insert adds an element anywhere in the list that you specify! Friends = [‘Tom’, ‘Sue’, ‘David’, ‘Barry’] Friends.append(‘Barry’) Friends.insert( 2, ‘ Jo ’) Friends = [‘Tom’, ‘Sue’, ‘ Jo ’, ‘David’, ‘Barry’] positionElement to insert

Inserting all the letters of a phrase into a list… for x in range(len(phrase)): myList.insert(x,phrase[x]) phrase = ‘joker’ ## or phrase = input(‘Please enter a word’) myList = [] #an empty list Determine length of the phrase For every letter in the phrase 0, phrase[0] is ‘j’ 1, phrase[1] is ‘o’ 2, phrase[2] is ‘k’ [‘j’] [‘j’, ‘o’,] [‘j’, ‘o’, ‘k’] 3, phrase[3] is ‘e’ [‘j’, ‘o’, ‘k’, ‘e’]

Task 1 Creating a list Create a list called friends. At design time (ie. when you are coding) add 5 of your friends/neighbours to the list. Output the contents of the list. Task 2 …adding to your list Amend your program so that the program prompts the end user for a name during (run time) The name entered at runtime should be added to the end of the list. Decide which list.method you will use to achieve this. Task 3 …refining to your list Amend your program so that the program continually prompts the end user for a name… The end user will be asked ‘Do you want to add a new friend? Type Y to continue or N to quit. If the end user types ‘Y’ then it will prompt them for a new name to be added to the list. If the end user types ‘N’ then it will say, ‘you have no more friends…goodbye!’ Task 4 …a third option (see the list) Amend your program so that there is a third option. Ie. Y to add to list, N to finish adding and S to see (i) the entire friends list and also (ii) the number of friends in the list.

in operator This will allow you to test if an item is in a list. ‘Mary’ in my_list >>> True my_list = [‘Jo’,’Fred’,’Mary’] This will return a Boolean value (True or False) min and max operator …you’ve guessed it. These list methods will return the smallest and largest values in a list my_list = [‘Jo’,’Fred’,’Mary’] min(my_list) ‘Fred’ max(my_list) ‘Mary’

Task 1 Your friends program At present your program should give the options: Y – add a new friend (to list) N – Quit the program (‘You have no more friends…goodbye!’) S – To see your list of friends ( print(friend_list)) …ensure then, that you have the following feature added to your Friend Program R – Removes a friend from the list…that you specify. e.g. friend_list = [‘Tom’, ‘Martha’, ‘Bert’] Friend_list.pop(1) Friend_list = [‘Tom’, ‘Bert’] Remember, pop can also remove an element anywhere in the list…not just at the end! Please note: I’d like you to ask the end user for the name of the friend they’ve fallen out with! (Pop’em!) Task 2 Refinement to Friends Program Add a new menu option that allows the end user to search whether a friend is in the list. E.g. Search(Tom) checks whether Tom is in friend_list.