TORONTO KIDS COMPUTER CLUB | Wednesday 17:00 Python Practice – 22.12.07.
21526
post-template-default,single,single-post,postid-21526,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Wednesday 17:00 Python Practice – 22.12.07.

13 Dec Wednesday 17:00 Python Practice – 22.12.07.

Question 1:
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
Spinners

Sample 2
How many times did reindeer shake its tail?
2
How many times did reindeer nod its head?
3
Spinners
LEGOs

Sample 3
How many times did reindeer shake its tail?
8
How many times did reindeer nod its head?
6

Question 2:
Ken is working for the secret agency. He is going to send a secret message that encodes UPPERCASE words by shifting their letters forward.

Shifting a letter by S positions means to go forward S letters in the alphabet. For example, shifting B by S = 3 positions gives E. However, sometimes this makes us go past Z, the last letter of the alphabet. Whenever this happens we wrap around, treating A as the letter that follows Z. For example, shifting Z by S = 2 positions gives B.

Ken’s code depends on a parameter K and also varies depending on the position of each letter in the word. For the letter at position P, they use the shift value of S = 2*K+3*P.

For example, here is how “FIND” is encoded when K = 3. The first letter F has a shift value of S = 2 × 3 + 3 × 1 = 9; it wraps around and becomes the letter O. The second letter, I, has S = 2 × 3 + 3 × 2 = 12 and becomes U. The last two letters become C and V. So Ken sends the secret message: OUCV

Write a program to encode messages sent by Ken.

Input Specification
The input will be two lines. The first line will contain the positive integer K (K < 10), which is used to compute the shift value. The second line of input will be the original word, which will be a sequence of uppercase characters of length at most 20.

Output Specification
The output will be the encoded word of uppercase letters.

Sample Input 1
3
FIND

Output for Sample Input 1
OUCV

Sample Input 2
5
MISSILE

Output for Sample Input 2
ZYLOHNJ

Question 3:
Anna and Jack are playing a game.

Each player starts with 100 points. The game uses standard six-sided dice and is played in rounds. During one round, each player rolls one die. The player with the lower roll loses the number of points shown on the higher die. If both players roll the same number, no points are lost by either player.

Write a program to determine the final scores.

Input Specification
The first line of input contains the integer n (1 ≤ n ≤ 15), which is the number of rounds that will be played. On each of the next n lines, will be two integers: the roll of Anna for that round, followed by a space, followed by the roll of Jack for that round. Each roll will be an integer between 1 and 6 (inclusive).

Output Specification
The output will consist of two lines. On the first line, output the number of points that Anna has after all rounds have been played. On the second line, output the number of points that Jack has after all rounds have been played.

Sample Input
4
5 6
6 6
4 3
5 2

Output for Sample Input
94
91

Explanation of Output for Sample Input
After the first round, Jack wins, so Anna loses 6 points. After the second round, there is a tie and no points are lost. After the third round, Anna wins, so Jack loses 4 points. After the fourth round, Anna wins, so Jack loses 5 points. In total, Anna has lost 6 points and Jack has lost 9 points.

No Comments

Sorry, the comment form is closed at this time.