Write a cipher program to encrypt or decrypt the given text

Assignment Help Python Programming
Reference no: EM133143737

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. ,

Programming Tasks

"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."
]
},

Task 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.

Task 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,

Task 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.,

Task 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)."

Task 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

Reference no: EM133143737

Questions Cloud

What are the relevant internal costs for All-Alone : All-Alone will eliminate $25,000 of fixed overhead if it accepts the proposal. What are the relevant internal costs for All-Alone
Industry overview in canada : Required to provide an overview of the trucking industry in Canada, including key statistics that profile the industry's importance to the economy. Key statisti
Identify an ethically questionable behaviour : 1. Identify an ethically questionable behaviour or decision that you have encountered (preferably in your work or school life) you could pick an unethical behav
What would monthly cost of operatives wages in the factory : Unavoidable non-productive time is 25% of productive time and is paid £9 per hour. What would monthly cost of operatives wages in the factory
Write a cipher program to encrypt or decrypt the given text : 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
What is the process of creating a budget : What is the process of creating a budget? How is accounting related to your position as Director within a health care group practice
What amount should be accounted for in special revenue fund : Using information, what amount should be accounted for in a special revenue fund or funds - Equipment used for supplying electric power to residents $1,750,000
How much money will she have : Ximena received a gift of $69564 from her rich auntwhich she is investing at a rate of 3.1%. How much money will she have in 15 years
What amount should be reported as gross sales : Purchase returns amounted to P400000 of which P100000 was received from supplier. Under accrual, what amount should be reported as gross sales

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd