Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Week 6 : Sequences ( lists, strings, and tuples )."— Presentation transcript:

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

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

3 Task 1 : Fibonacci number  For your information, refer this definition of Fibonacci number.  http://en.wikipedia.org/wiki/Fibonacci_number http://en.wikipedia.org/wiki/Fibonacci_number  Using while-loop, you should fill a list with these Fibonacci numbers which are less than 1000.  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] >>>

4 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.......... 3rd 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

5 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 :

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

7 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.

8 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. ….

9 Rock and Roll!


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

Similar presentations


Ads by Google