ICS3U Python Programming Evaluation 7

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.

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

Please keep in mind, that you are only allowed to use the python functions that have been discussed in class.  Using other things you might find on the internet will invalidate your solution.  

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

B3 – Algorithm Design

  • Design and implement algorithms that solve problems

ICS3U Python Programming Evaluation Question 1

File Name: “ICS3UhexNibbles.py”

Write a function that takes as an argument, a 4 bit binary nibble represented as a string, and returns its hex equivalent value as a String 

Use that function to write a program that accepts an entire string of binary nibbles entered from the keyboard and prints out the full hex equivalent. The nibbles in the input must be separated by spaces.

For Example:

  • An input of 0101 1101 produces an output of 5D
  • An input of  0000 1001 0001 1111 1100 produces an output of 091FC

ICS3U Python Programming Evaluation Question 2

File Name: “ICS3UcubeMe.py”

Write a function that takes as an argument, an integer number with a maximum of 8 digits, and returns the sum of the cubes of the digits in the number

For Example:

  • 215 would return 2*2*2 + 1*1*1 + 5*5*5 = 134

Write a program that accepts an integer number from the keyboard and then uses the function above to test if the inputted number has the property that the sum of its cubed digits equals the number itself.

For Example:

  • If the user input was 371 then that input would satisfy this property since 3*3*3 + 7*7*7 + 1*1*1  = 371

Allow you program to continue forever until an input of 0 is made.  A simple  “Yes” or “No” is sufficient as output in this program

ICS3U Python Programming Evaluation Question 3

File Name: “ICS3UtheNthMax.py”

Write a function that accepts a list of integers, and returns True or False depending on if the integers in the list are all unique or not

Write another function that generates a unique list of random integers and returns a list of those values.  Use the previous function to help you with that task.  The function should accept 3 arguments:  The number of values to generate, and the starting and ending values for the random numbers.

 Write another function that can determine the nth largest number from a unique list of integers. It should accept the list and the value of n as arguments, and return the required maximum.

For Example:

  • If your list has the values 1 3 7 2 15 20 5 18 11 and the user wanted the:
    • 1st Maximum (n = 1)  -> It would return 20 (the highest number)
    • 2nd Maximum (n = 2) -> It would return 18 (the second highest number)
    • 3rd Maximum (n = 3) -> It would return 15 (the third highest number)

Main Program.

You should ask the user to input the following:

  • Number of Values they wish to generate
  • The Range of values in the list
  • The nth maximum value they wish to find
Build in some error checking to make sure the user can’t enter any values that would make the program crash.

Output:

  •  Display the unique list and the number the user requested.