Week 6 : Sequences ( lists, strings, and tuples ).

Slides:



Advertisements
Similar presentations
Tri-math-lon Relations and FunctionsRelations and Functions Writing Linear EquationsWriting Linear Equations GraphingGraphing.
Advertisements

QUIZ-A QUICK PROGRESS CHECK ON YOUR UNDERSTANDING.
Building Java Programs
ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
D IVIDE AND CONQUER STRATEGY, D ATA TYPE, A LGORITHM DESIGN AND PRACTICE. Week 13 Mr.Mohammed Rahmath.
ECS15 sequence. Sequences  There are three kinds of sequences in Python: Strings – we use these a lot. “albatross” Lists – we saw those last time, they.
CSE 115 Week 12 March 31 – April 4, Announcements March 31 – Exam 8 March 31 – Exam 8 April 6 – Last day to turn in Lab 7 for a max grade of 100%,
CS 201 Functions Debzani Deb.
V Avon High School Tech Club Agenda Old Business –Delete Files New Business –Week 18 Topics: Intro to HTML/CSS: Questions? Summer Work Letter.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Introduction to Python
JavaScript Lecture 6 Rachel A Ober
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Module 3 Fraser High School. Module 3 – Loops and Booleans import statements - random use the random.randint() function use while loop write conditional.
If statements while loop for loop
Flow of Control Part 1: Selection
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Implementation of the Hangman Game in C++
Week 3 : Last step with Hubo, Python objects
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Project Log. Initial Plan 11/09/12 In todays lesson I started my initial plan. I set out the structure, checking I had included all the columns and necessary.
Course A201: Introduction to Programming 09/30/2010.
SD1230 Unit 6 Desktop Applications. Course Objectives During this unit, we will cover the following course objectives: – Identify the characteristics.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
Decision Structures, String Comparison, Nested Structures
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Food and Exercise analysis Website for entering food and exercise
Week 4 : Function with parameters and return values.
Logical Operators, Boolean Variables, Random Numbers This template was just too good to let go in one day!
2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
Week 9 : Text processing (Reading and writing files)
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
CPSC 217 T03 Week V Part #1: Iteration Hubert (Sathaporn) Hu.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Week 8 : User-Defined Objects (Simple Blackjack Game)
A Level Computing#BristolMet Session Objectives#U2S11 MUST identify built-in string manipulation functions SHOULD correctly use string manipulation functions.
Data Structures Arrays and Lists Part 2 More List Operations.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
CSx 4091 – Python Programming Spring 2013 Lecture L2 – Introduction to Python Page 1 Help: To get help, type in the following in the interpreter: Welcome.
Introduction to: Python and OpenSesame FOR PROS. OpenSesame In OpenSesame you can add Python in-line codes which enables complex experiment. We will go.
Lab 4 Instructions If you have a text book, you can go to drill at pp. 126 for steps 1-6 at the end of chapter 4, Or you can read following slides of the.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
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.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Chapter One Problem Solving
Introducing Instructions
Topic: Conditional Statements – Part 1
Containers and Lists CIS 40 – Introduction to Programming in Python
Programming Languages Dan Grossman 2013
Introduction to Programmng in Python
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Learning to Program in Python
Decision Structures, String Comparison, Nested Structures
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Resetting a Credit/ Debit card transaction
Faculty of Computer Science & Information System
3. Decision Structures Rocky K. C. Chang 19 September 2018
4n + 2 1st term = 4 × = 6 2nd term = 4 × = 10 3rd term
Python programming exercise
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Introduction to Python
Presentation transcript:

Week 6 : Sequences ( lists, strings, and tuples )

Today’s topic  Fibonacci number  Task1  Memento game  Task2-1  Task2-2

Task 1 : Fibonacci number  For your information, refer this definition of Fibonacci number.   Using while-loop, you should fill a list with these Fibonacci numbers which are less than  Printed result of the list  We recommend you to start with two initial values, 0 and 1. >>> [evaluate fibonacci.py] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] >>>

Memento game  Today we’ll implement a Memory test game, “Memento” ### Welcome to the Python Memento game!!! ### 1st try. You got 0 pairs. Input the first card number : 0 Input the second card number : 4 Correct! 2nd try. You got 1 pairs. Input the first card number : 10 Input the second card number : 19 Wrong rd try. You got 1 pairs. Input the first card number : 8 Input the second card number : 19 Correct! 4th try. You got 2 pairs. Input the first card number : 10 Input the second card number : 14 Correct! ……. Game goes on ……… Python shell

The flow of Memento game  There are 24 number pads.  First, show all pictures for a while then flip them over  The user have to input 2 card numbers.  The screen shows two pictures you indicated  If the card numbers(indices) indicate the same picture, then show “Correct!” message and add 2 numbers to correct number list, and show all the picture pairs which you have founded.  If not, show “Wrong……” message and return the screens before.  The game finishes when all pairs are founded. >>> [evaluate memento.py] ### Welcome to the Python Memento game!!! ### 1st try. You got 0 pairs. Input the first card number :

num_pads correct_list.... Suwon.jpgSungeun.jpgYeongjae.jpg cards Two lists for visualization A list for managing corrected numbers Three lists in Memento game 8

Task 2-1 : Implementation - Function  Implement two functions: 1.is_valid(num1,num2)  Check if any of two numbers exists in the current correct list, the two are same number, or they are valid numbers in the given range.  Return Boolean value according to the result. 2.check(num1,num2)  At first, visualize the screen including the two cards (num1 th card and num2 th card).  If two pictures of the two cards are same, put the two numbers into the correct list.  If not, re-visualize the original screen.  Return Boolean value according to the result.

Task 2-2 : Implementation - Others 1.Shuffle the “cards” list.  Using “random” module. 2.Modify the condition for visualization in print cards(). 3.Modify the condition of main while-loop.  Your program should be terminated if you find all pairs. 4.Print the number of tries using the ordinal number. >>> [evaluate memento.py] ### Welcome to the Python Memento game!!! ### 1st try. You got 0 pairs. 2nd try. You got 0 pairs. 3rd try. You got 0 pairs. ….

Rock and Roll!