## 14 Dec Monday 19:00 Python Practice – 22.12.12

**Question 1：**

Santa Claus is playing card game with his reindeer to decide which route he’s going to take to send out the gifts. He is going to play six games. There are no ties. The gift route will be decided based on the results of games as follows:

if Santa wins 5 or 6 games, he’s going to take Route 1;

if Santa wins 3 or 4 games, he’s going to take Route 2;

if Santa wins 1 or 2 games, he’s going to take Route 3;

if Santa does not win any games, he will stay at home.

Write a program to determine which route Santa will going to take.

The input consists of six lines, each with one of two possible letters: W (to indicate a win) or L (to indicate a loss).

Sample Input 1:W L W W L WSample output 1:Route 2Sample Input 2:L L L L L LSample output 2:Stay home

**Question 2:**

Santa Claus is wondering which extra gift(s) he’s going to send out for each kids. Eventually, he is going to use his reindeer to determine which gift(s) to give. There are only 3 types of gifts to give:

• Nerf Guns if the reindeer shook its tail at least 3 times and nodded its head at most 4 times;

• Spinners if the reindeer shook its tail at most 6 times and nodded its head at least 2 times;

• LEGOs if the reindeer shook its tail at most 2 times and nodded its head at most 3 times.

Input Specification

The user will be prompted to enter two numbers. First, the user will be prompted to enter the number of times the reindeer shook its tail. Second, the user will be prompted to enter the number of times the reindeer nodded its head.

Output Specification

The output will be the gifts given out match the signals given by the reindeer. If no gift match the signals, there is no output.

Sample 1 (with output shown in text, user input in italics)How many times did reindeer shake its tail? 4 How many times did reindeer nod its head? 5 SpinnersSample 2How many times did reindeer shake its tail? 2 How many times did reindeer nod its head? 3 Spinners LEGOsSample 3How many times did reindeer shake its tail? 8 How many times did reindeer nod its head? 6

**Question 3:**

We have a list of following:

zoo = ['monkeys', 'tigers', 'pandas', 'penguins', 'giraffes', 'hippos', 'bears']

how to retrieve a slice of list zoo, so you can get the following results?

['tigers', 'pandas', 'penguins', 'giraffes'] ['hippos', 'bears']

Sorry, the comment form is closed at this time.