Assignment Detail:- Instructions
"This assignment is structured similarly to the labs, and as such the instructions are similar:," - Read each question thoroughly multiple times to ensure that you understand the requirements-," - Once you understand the question, code your solution in the associated code cell titled \"Your Solution\"-," - Test your solution multiple times, with a variety of inputs---not just those found in the example runs-," - Keep in mind that partial attempts at solutions will likely still be worth some marks, so be sure to have a go at writing code for every task- ,
"This assignment consists of five programming tasks, with a total of 100 marks allocated between them according to their difficulty-,","Take your time to read and re-read the instructions before attempting to write your solution---you can save a lot of trouble by simply having a clear understanding of the problem before touching any code-"-},
Part 1"For this task, you are to write a cipher program to encrypt or decrypt the given text message -`strings`-- The cipher algorithm uses the pre-defined `key` and `rules` to convert the original text message -`strings`- into a ciphertext -`strings`-- Specifically, the rules use the key to replace each letter of the original text message by another letter- A very simple set of rules is to replace letter $a$ with letter $z$, letter $b$ with letter $y$, letter $c$ with letter $x$, letter $d$ with letter $w$, ---, etc- For this task, you should use the following key ,","`key ='xznlwebgjhqdyvtkfuompciasr'`,","Based on the above `key`, letter `a` should be replaced by letter `x`, letter `b` should be replaced by letter `z`, letter `c` should be replaced by letter `n`, ---, and so on-,"
Instructions,","Your task is to write the following functions:,"-\tThe encrypting function which accepts a list of strings and converts it into ciphertext -`strings`--,"-\tThe decrypting function which accepts a list of ciphertext -`strings`- and retuns it back to the original strings-,"- The menu -options- function which display the available options for the user to select:," `E: Encrypting function`," `D: Decrypting function`," `EX: exit`," ,"-\tThe main function which involves the following:,"," - The key and any other parameters, variables, ---etc -if needed-," - The input function to get input from user," - A loop of menu -or options- which asks the user to select either the Encrypting function, the Decrypting function or exit- The loop -menu- should be repeated unless the user selects exit option-
Part 2 "For this task, you are to re-write the given program -BMI Program- to make it more robust by raising exceptions upon invalid inputs and handling the raised exceptions-" -
Requirements,"To achieve full marks for this task, you must follow the instructions above when writing your solution- Additionally, your solution `must adhere` to the following requirements:," - You **must** print the result of the `Encrypting` function -`ciphertext`- and `Decrypting function` -`original strings`- inside the `main` function- ," - You **must** address the scenario when an `empty` list is passed in as argument to your function- The `main` function should ask the user that the input should be non-empty strings- ," - You **must not** add any code outside the `main` function- "
Instructions,"The program calculates the BMI -body mass index- of a person- A user can key-in invalid inputs, which causes the program to crash- Your task is to handle the invalid inputs and results using exception handling concepts-"
Requirements,"To achieve full marks for this task, you must follow the instructions above when writing your solution- Additionally, your solution must adhere to the following requirements:," - The program **must** handle all invalid inputs or results-," - You **must** not use if-condition to handle invalid inputs or results-," - You must use `EAFP` principle only,"- You must use `try, except` and `raise` statements concepts,
Part 3"For this task, you are to write a simple program to read data from a text file, reorder the data, and then write the reordered data into a new file-"
Instructions,"- Download the input_file-txt file into your PC's working directory -or the folder-- The file is available in Programming Assignment 2 -instructions and submission- section-,"- You need to read the data from the input file -named as input_file-- The data consists of multiple-choice questions- ,"- You should **randomly** **reorder** the choices for each question-,"- You should write the reordered data into a new file, named as new_file-,
"1- What is the capital of Australia????<br>,"-a- Canberra<br>,"-b- Perth<br>,"-c- Sydney<br>,"-d- Melbourne<br>,","And here is what it might look like, for example, after reordering the choices for each question,","1- What is the capital city of Australia????<br>,"-a- Sydney<br>,"-b- Melbourne<br>,"-c- Perth<br>,"-d- Canberra<br>
Requirements,"To achieve full marks for this task, you must follow the instructions above when writing your solution- Additionally, your solution must adhere to the following requirements:," - You **must** NOT change the format of the input file or the output file- ," - Your program **must** ready any file with any number of questions- The given file contains 4 questions only, but the program should read any file and reorder the choices regardless of the number of questions- ," - You **must** handle the situation if the file does not exist-,
Part 4"For this task, you are to write code that handles the transfer of data between two mobile accounts-"Instructions,"These days, many mobile phone plans allow us to transfer data with a friend or a family member who has a plan with the same provider- In this task, you are required to write a program that handles the transfer of data between two mobile plans -i-e-, accounts-- ,","As this task relates to tranferring data between mobile accounts, a `MobileAccount` class has been provided, which supports receiving and sending data- A simple interactive loop has already been implemented, which allows the user to repeatedly transfer data from one account to another-,Part A"You are to write a function called `transfer_data` with three parameters: the amount of data to transfer in gigabytes, the account the data is coming from, and the account the data is going to- It should use the appropriate instance methods on each of the accounts to update their data balances as required-,",Part B"If you tested your solution thoroughly in the previous part, you probably came across a logic error in the program---there's nothing to stop us from transferring data from an account, even if the account's data balance becomes negative! You are to fix this problem by raising an exception and preventing the account's data balance from becoming negative- You should do this by raising a `ValueError` in the appropriate place in the `MobileAccount` class-,","_Hint: The order in which data is sent and received in `transfer_data` matters---the wrong order will result in the creation of free data!_,",Part C"At this point, the program prevents a transfer occurring if there isn't enough data in the \"from\" account- However, simply crashing a program isn't a very nice user experience- You are to modify your program so that it handles the `ValueError` and displays `<<Error: Insufficient data>>` to the user- The program should otherwise continue as normal, with the user being asked whether they would like to perform another transaction- A failed transaction should not result in either account's data balance changing-,",
Requirements,"To achieve full marks for this task, you must follow the instructions above when writing your solution- Additionally, your solution must adhere to the following requirements:," - The `transfer_data` function **must not** directly access the `balance` instance variable of either mobile account-," - You **must** raise an exception from within the `MobileAccount` class if sending a certain amount of data would cause an account's data balance to become negative-," - You **must** specify the appropriate exception type when handling the exception-," - The `transfer_data` function call **must** be the only thing in your `try` block-," - A failed transaction **must not** change either mobile account's data balance -i-e- the total data of the accounts should never change--"
Part 5"For this task, you are to graph the physical characteristics of penguins in different islands using Pandas and Matplotlib- The data is named as "
Instructions"Download the `**penguins-csv**` dataset into your PC's working directory -or the folder-- The dataset is available in Programming Assignment 2 -instructions and submission- section-,","This task uses a dataset containing some physical measurements of three different penguin species- The data have been collected from three islands: Torgersen, Dream, and Biscoe- You can view the dataset using Microsoft Excel- Run the following code cell to load the dataset into a Pandas DataFrame and look at the first few rows- Read through the code before executing it-"
Attachment:- Programming Assignment-rar
Most Recent Questions