## 11 Aug Aurora Saturday 14:30 Python Practice 20.08.08.

**Question 1:**

Today in gym class, your class decided to play dodgeball, and Jack is selected as one of the team captains! ** N** students are lined up in a row, waiting to be put on teams. Jack is allowed to pick multiple students as long as they are adjacent to one another, and the first letter of each of their names are the same (case insensitive).

As an assistant to Jack, help him decide what his first choice should be by writing a program to determine all the possible choices he could make!

**Input Specification**The first line contains the integer

**(1≤**

*N***≤105), representing the total number of students.**

*N*The second line contains ** N **space separated strings, each representing the name of the

**th student in line. Each name will be no longer than 20 characters and only contain letters from the English alphabet.**

*i***Output Specification**

Output one integer, representing the total number of choices Jack can make.

Sample Input5 Sarah Timmy Turner Betty BobSample Output7Explanation for Sample InputThe possible groups of people that aurpine could choose are: Sarah Timmy Turner Betty Bob Timmy, Turner Betty, Bob

**Quesion 2:**

Modify the infixToPostfix function so that it can convert the following expression: 5 * 3 ** (4 – 2).

**Question 3:**

You take part in a competition and get good score. So you decide to add it to your resume. However, the released results only include the average rank for each of the attained scores. You think that might not be enough information, and want to include the exact range in which your score falls (i.e. if there are 25 people with scores better than yours, and 3 people tied with you, the range would be 26-29).

Furthermore, you want to build a program that would handle possible future situations in which the range of the scores, as well as the number of contestants, have greatly increased. You also want your program to work even if the scores are not necessarily given to you in order.

**Input Specification**

The first line of the input file will contain an integer ** N** between 1 and 100000, inclusive.

* N *lines will follow, containing the scores that were attained in the contest, as well as the average rank for each of them. Each of them will contain two numbers, separated by a space. The first number will be between 0 and 3×10

^{9}, inclusive. It will correspond to a score that was attained in the contest by some people. The second number will be a decimal number between 0 and 3×10

^{8}specified using the format in the sample input, and it will contain the average rank corresponding to that score.

The last line of the input contains your score in the competition. You may assume that this number appears as the first number in one of the previous * N *lines.

**Output Specification**

You will output two lines. They will contain the range corresponding to the rank of your score.

Sample Input:6 5 2 4 10 3 20.5 1 34 0 35 2 29 4Output for Sample Input:4 16Explanation: The average rank of score 5 is 2, that means there are 3 people got score 5, the range of corresponding to the rank of score 5 is 1 to 3. Then the score next lower than 5 is 4. And the rank range of score 4 will follow the previous range (1~3) which starts from 4. The range of score 4 is 4 to 16, so we can get the average rank of score 4 is 10.Hint: You may use list in the list or dictionary to do this homework List in the List example: >>> aList = [[2, 4], [5, 8], [3, 2]] you can sort aList by using: >>> aList.sort(reverse = True) Dictionary example, try the following: >>> d = {} >>> d[2] = 4 >>> d[5] = 8 >>> d[3] = 2 >>> print(d) {2: 4, 5: 8, 3: 2} if you would like to get value 8, you need to enter: >>> print(d[5])

Sorry, the comment form is closed at this time.