ICS3U Python Programming Evaluation 8

Instructions

These ICS3U Grade 11 Computer Science python coding questions will form a part of your final grade for this course and are to be handed in for grading. 

For all of the following questions:

  • Use a Python IDE of your choice (Spyder, IDLE, Pycharm, etc) and create a coded solution to the given problem.
  • Hand in the .py files for your solution.
  • Some Questions will require you to hand in Planning Documents and Testing Evidence

Your grade will be based on your ability to demonstrate the overall expectations from the Ontario Computer Studies Curriculum

YOU ARE NOT ALLOWED TO USE ANY FUNCTIONS OR DATA TYPES OR OBJECTS NOT TAUGHT IN THE COURSE (THAT INCLUDES SORTING FUNCTIONS, DICTIONARIES, FRACTION OBJECTS) TO SOLVE THESE PROBLEMS.  

A1 – Data Sequencing 

  • Use variables to carry out mathematical calculations in a computational problem
  • incorporate one dimensional arrays into a computer program

A2 – Selection and Repetition Structures

  • Incorporate selection structures into a computer program.
  • Incorporate repetition structures into a computer program

A3 – Modular Programming

  • Write custom subprograms that pass parameters and return results

A4 – Code Maintenance

  • Write code that is readable using proper naming, indenting, and commenting conventions
  • Test program thoroughly to identify and correct errors

B1 – Problem Solving Strategies

  • Incorporate the Input – Processing – Output model of problem solving

B2 – Planning

  • Describe the structure of a program using pseudocode or flow charts

B3 – Algorithm Design

  • Design and implement algorithms that solve problems

Mandatory Questions

The following 2 Questions MUST be completed.  

  • They are worth 60% of the grade for this Evaluation
  • Complete the entire problem solving process for both these questions. Make sure to include the Planning Documents and Evidence of Testing
  • Your solutions must include some modular design using at least 1 function in either of the two solutions

Mandatory - ICS3U Programming Evaluation Question 1

File Name: “ICS3UbestComputer.py”

When determining which computer to buy, you narrow your search categories to :

  • RAM -> R
  • CPU Speed -> S
  • Drive Space -> D

The most preferred machines will have larger values of P where 

  • P = 2R + 3S + D

Your task will be to read a given list of computers and output the TOP 2 computers. 

Input:

Ask the user how many computers they are going to compare (this is an integer) Then for each computer the following will be entered all on the same line from the user (Separate values using a comma)

  • Computer Name, RAM Value, CPU Value, Drive Space Value

Output:

  • The Scores of all the computers with their names
  • The Top Computer Name with its score
  • The 2nd Best Computer Name with its score

Mandatory - ICS3U Programming Evaluation Question 2

File Name:  “ICS3Uintersection.py” 

You are designing a program that can find the point of intersection of 2 straight diagonal lines You don’t need to consider vertical or horizontal lines

Input

  • The first equation will be entered by inputting values (A,B,C) using the standard form of a linear equation Ax + By + C = 0
  • The second equation will be entered by inputting values(m,b) using the slope-intercept form of a linear equation y = mx + b

Output

  • The answer, an (x,y) ordered pair, should be displayed as both decimal and fractional values.
  • The fractions MUST be in lowest terms
  • Any negative fractions should display the negative only in the numerator.
The program should continue to execute forever until the user indicates he wishes to stop.

Advanced Questions

Complete as many of the questions as you are able to or have time to finish.  Your teacher will use his professional judgement to evaluate your programming skills and assign the last 40% of your assignment grade based on the solutions you create.  

  • It is not necessary to hand in any problem solving documentation for any of these questions.
  • All programs should be written using a modular approach using functions in the solution. 

Advanced - ICS3U Programming Evaluation Question 1

File Name: “ICS3UEmiliaNumbers.py”

A positive Integer will be an “Emilia Number” if it has at least two sets of factors where the sum of one set equals the difference of another set.

For Example:

  • 6 is an Emilia Number.  It has a sets of factors (6,1) and (2,3) where 2 + 3 = 6 – 1
  • 30 is an Emilia Number.  It has sets of factors (10,3) and (15,2) where 10 + 3 = 15 – 2
  • 84 is an Emilia Number.  It has sets of factors (21,4) and (28,3) where 21 + 4 = 28 – 3

Display all the Emilia #’s from 1 to 1000 (Make sure to display the two sets of factors)

Advanced - ICS3U Programming Evaluation Question 2

File Name: “ICS3UfourFive.py”

I want to know how many ways a certain number can be formed using a sum of only 4’s and 5’s.

For example, the number 14 has only 1 way to form it using 4’s and 5’s

  • 14 = 4 + 5 + 5

For example, the number 20 has 2 ways to form it using 4’s and 5’s

  • 20 = 4 + 4 + 4 + 4 + 4
  • 20 = 5 + 5 + 5 + 5

For example, the number 40 has 3 ways to form it using 4’s and 5’s

  • 40 = 4+4+4+4+4+4+4+4+4+4
  • 40 = 4 + 4 + 4 + 4 + 4 + 5 + 5 + 5 + 5
  • 40 = 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5

Output the total # of ways along with printing all possible sequences as shown in the examples

Advanced - ICS3U Programming Evaluation Question 3

File Name: “ICS3UrepeatCipher.py”

You are sending a message to your friend.  Instead of sending the actual message, you send a set of consecutive characters that represent the real letter.  The number of consecutive characters determines the real letter.

  • A single consecutive character represents the letter “A”
  • Two consecutive characters represents the letter “B”
  • Three consecutive characters represents the letter “C”
  • etc

If you sent the message:

  • ********bbbbb&&&&&&&&&&&&999999999999zzzzzzzzzzzzzzz

It would decode to HELLO because there are

  • 8 “*” characters in a row -> H
  • 5 “b” characters in a row -> E
  • 12 “&” characters in a row ->L
  • 12 “9” characters in a row ->L
  • 15 “z” characters in a row ->O

You need to write a program that DECODES messages 

Advanced - ICS3U Programming Evaluation Question 4

File Name: “ICS3UrebelAllianceCipher.py”

You are in charge of breaking Encrypted Rebel Communications for the Empire.

You have managed to plant an Imperial Spy inside the Alliance and every morning they manage to steal some very valuable information. They manage to steal both an encrypted message and its decoded equivalent. They have also figured out that the Rebel Alliance used a simple one to one code map to encrypt their messages. That means that each letter in the message was substituted for a different letter for the encryption. Simply comparing the two messages together you can see what letter was substituted.

You want to use this information decode all rebel communications for the rest of the day until they switch out to a new substitution.

Example:

If you acquired a message from your spy with the entire alphabet, then you can fully decode all the rebel communications because you have a complete mapping of the alphabet they used.

Stolen Message From Spy: (Both the Decoded an Encoded Version)
Another Intercepted Message You Want to Decode:
Your Program should be able to decode that new intercepted message to the following:

Example:

If you acquired a message that only had some of the letters, there will be a limit on how much you can decode.

Stolen Message From Spy: (Both the Decoded an Encoded Version)
Another Intercepted Message You Want to Decode:
Your Program should be able to decode that new intercepted message to the following:

Notice the decoded message is incomplete because the stolen encoded message didn’t have any mappings for the letters M, E, H back to the real message, so there is no way to tell what they represented. 

What do you need to do?

Input:

  • Stolen Spy Messages:
    • The decoded version 
    • The encoded version
  • Another Intercepted message you want to decode
Note: The input will be all uppercase, with only spaces as punctuation.

Output:

  • The decoded version of the other intercepted message.
    • If you don’t have enough letters, then use a “.” in your decoded output.
 

Although not required you might want to write a program to encode messages as well so you can test using data other than my examples.