TORONTO KIDS COMPUTER CLUB | PMCA Saturday 18:30 Python Homework 20.12.26.
18887
post-template-default,single,single-post,postid-18887,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

PMCA Saturday 18:30 Python Homework 20.12.26.

30 Dec PMCA Saturday 18:30 Python Homework 20.12.26.

Question 1:
A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:

  • there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call “Fish Rising”), or
  • there are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call “Fish Diving”), or
  • there are four consecutive depth readings which are identical (which we will call “Constant Depth”).

All other readings will be considered random noise or debris, which we will call “No Fish.”

Your task is to read a sequence of depth readings and determine if the alarm will sound.

Input Specification
The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.

Output Specification
The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should be Fish At Constant Depth. Otherwise, the output should be No Fish.

Sample Input 1
30
10
20
20

Output for Sample Input 1
No Fish

Sample Input 2
1
10
12
13

Output for Sample Input 2
Fish Rising


Question 2:
A vote is held after singer A and singer B compete in the final round of a singing competition. Your job is to count the votes and determine the outcome.

Input Specification
The input will be two lines. The first line will contain V (1 ≤ V ≤ 15), the total number of votes. The second line of input will be a sequence of V characters, each of which will be A or B, representing the votes for a particular singer.

Output Specification
The output will be one of three possibilities:

  • A, if there are more A votes than B votes;
  • B, if there are more B votes than A votes;
  • Tie, if there are an equal number of A votes and B votes.
Sample Input 1
6
ABBABB

Output for Sample Input 1
B

Sample Input 2
6
ABBABA

Output for Sample Input 2
Tie


Question 3:
Your teacher likes to give multiple choice tests. One benefit of giving these tests is that they are easy to mark, given an answer key. The other benefit is that students believe they have a one-in-five chance of getting the correct answer, assuming the multiple choice possibilities are A, B, C, D or E.

Write a program that your teacher can use to grade one multiple choice test.

Input Specification
The input will contain the number N (0<N<10000) followed by 2N lines. The 2N lines are composed of N lines of student responses (with one of A, B, C, D or E on each line), followed by N lines of correct answers (with one of A, B, C, D or E on each line), in the same order as the student answered the questions (that is, if line i is the student response, then line N+i contains the correct answer to that question).

Output Specification
Output the integer C (0≤C≤N) which corresponds to the number of questions the student answered correctly.

Sample Input 1
3
A
B
C
A
C
B

Output for Sample Input 1
1


Sample Input 2
3
A
A
A
A
B
A

Output for Sample Input 2
2
No Comments

Sorry, the comment form is closed at this time.