10 Sep HIT137 Assignment 1, 2020 How to submit this assignment Your submission should
HIT137 Assignment 1, 2020
How to submit this assignment Your submission should be written in a single PY file.
Save the py file using your lastname_firstname.py for example: Azam_Sami.py
Put all the solutions in one single PY file and then you can use Case-Switch statement to allow the user to select which program should run first. I will show you how to use Case-Switch statement in the coming class. It is easy to use and gives you the flexibility to put your all solutions in one PY file.
Clearly label each question and any sub-sections. Provide maximum possible comments so the code becomes easier to read. If your submission is difficult to understand, you will lose marks. IMPORTANT TO NOTE: DO NOT use functions / commands to solve problems which were not taught in the class.
Question 1 Marks 6 Assume s is a string.
Write a program that prints a substring of numbers, the longest substring of s in which the numbers occur in descending order and compute the average of the numbers found. For example, if s = ’56aaww1984sktr235270aYmn145ss785fsq31D0′, then your program should print.
Keep in mind – you need to accept the string from the user.
Sample Input / Output
String of numbers: ‘561984235270145785310’
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Longest substring in numeric descending order is: 014578
Average: 4.167
In the case of ties, print the first substring. For example, if s = ’14erq72lkm79′, then your program should print
String of numbers: ‘147279’
Longest substring in numeric descending order is: 147
Average: 4
Question 2 Mark 6 Write a program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces.
Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user
For Encryption:
Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x) given by the user.
For Decryption:
Take the string and reverse the string. Decrypt the reverse string with each character replaced with distance value (x) given by the user.
Sample:
String input – cdu
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Encryption process – udc -> xgf (encrypted)
The program should ask the user for input to encrypt, and then display the resulting encrypted output. Next your program should ask the user for input to decrypt, and then display the resulting decrypted output.
Enter phrase to Encrypt (lowercase, no spaces): cdu
Enter distance value: 3
Result: xgf
Enter phrase to Decrypt (lowercase, no spaces): xgf
Enter distance value: 3
Result: cdu
Question 3 Mark 12 There is a file attached with your assignment, named mailbox-short.txt.
Write a program to prompt for a file name, and then read through the file and look for lines of the form:
X-DSPAM-Confidence: 0.8475
When you encounter a line that starts with “X-DSPAM-Confidence:” pull apart the line to extract the floating-point number on the line. Count these lines and then compute the total of the spam confidence values from these lines. When you reach the end of the file, print out the average spam confidence.
Your sample output of the program should be:
Enter the file name: mailbox-short.txt
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Average spam confidence: 0.894128046745
The End!!!
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteEdu. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
Do you need help with this question?
Get assignment help from WriteEdu.com Paper Writing Website and forget about your problems.
WriteEdu provides custom & cheap essay writing 100% original, plagiarism free essays, assignments & dissertations.
With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Chat with us today! We are always waiting to answer all your questions.