Python代写 | COMP90059 Assignment 1

Python基础编程要求能过网络测评

COMP90059 Introduction to Programming Semester 2, 2019
School of Computing and Information Systems The University of Melbourne
Assignment 1
Due date: Sunday 8th September 2019, 11.30pm
This assignment is worth 20 marks, and will count as 10% of your final mark in this subject. The assignment specification is on the COMP90059 GROK environment, under the heading ‘Assignment 1’ (https://groklearning.com/learn/unimelb-comp90059-2019-s2/ass1/0/).
There are FOUR (4) questions in this assignment worth a total of 20 marks (accounting for 10% towards your final mark). Answer all four questions. This is an individual project. While you may discuss the problems with your classmates, you must not show written solutions to another student or use written solutions from another student.
You are reminded that your submission for this project is to be your own individual work. For most people, collaboration will form a natural part of the undertaking of this project. However, it is still an individual task, and so reuse of code or excessive influence in algorithm choice and development will be considered misconduct. We will check submissions for originality and will invoke the University’s Academic Mis- conduct policy (http://academichonesty.unimelb.edu.au/policy.html) where inappropriate lev- els of collusion or plagiarism appear to have taken place. Your code will be passed through our plagiarism software.
Late submissions: A 10% penalty will be applied for each ‘late’ day and no late submissions will be accepted after 5 days from deadline. If you submit after the deadline, your submission will be treated as late and will be penalised.
Marking Rubric for this assignment: A sample marking rubric is uploaded on the LMS for your informa- tion.
Note:
Three types of automated test cases will be run against your submission on GROK: (i) example test cases from the examples given to you in the specification – you will see a tick mark if you pass them; (ii) hidden test cases—you won’t see the test cases but you will receive a tick if your code has passed each of them; and (iii) assessment test cases, which you will not see, but the markers will see and use to assess your project. Read the specification carefully and follow the instructions for each question.
Only assessment test cases will be used to calculate your mark, as outlined in the marking rubric. Make sure to employ good programming strategies and use relevant comments and formatting of the code. Five (5) marks out of the 20 will be allocated to computational approach to solving the questions. One (1) mark is allocated to formatting, commenting and the use of descriptive variable names.
Good Luck!
Dr Antonette Mendoza, semester 2 2019
1

Background
In this assignment we are using Python concepts taught in weeks 1–5 of the semester. This includes • expressions, statements, programs, data types, operators and strings,
• built-in functions and methods, such as mathematical functions or string methods,
• control flow, such as making decisions, looping over a range, or advanced looping.
The assignment will be submitted via GROK and assessment will be carried out using GROK test cases. The questions have been entered into GROK and initial test cases provided to get you started. You are encouraged to generate your own test cases and test your code thoroughly to avoid surprises.
For each question, you are asked to write a short Python program. The program for each question will be self-contained and will use the input() function to gather information from the user (or the test case), and the print() statement to report its results.
Each question gives sample sessions with the program you are to write, giving the input and the required output. Due to the GROK assessment process, your output is required to match the sample exactly, including spacing. You should have practiced this procedure in the week 2–5 labs.
You are not expected to check the input for errors, and nor are you expected to print error messages or throw exceptions. On the other hand, there is no penalty for applying ordinary defensive programming practices.
Question 1 (3 marks): Valid IP Address?
Private usable IP addresses falls in the range 10.0.0.1 to 10.255.255.255 inclusive, meaning the first part must be 10, and the following parts must between 0-255, except for the last part it should be between 1-255. Write a program that takes as input an IP address and returns ”IP address is valid” if that input was a valid IP address, otherwise ”IP address is not valid”. The output must match the examples below.
Note that your program should deal with the leading zeros in each part of the IP address.
Here’s one example of how your program should work:
Enter IP address: 010.000.000.001
IP address is valid
Here’s another example:
Enter IP address: 10.0.0.0
IP address is not valid
Third example:
Enter IP address: 10.899.0.209
IP address is not valid
You may assume that all input to your program will consist of positive integers separated by full stops.
2

Question 2 (4 marks): Ewwoks everywhere
Consider a special type of animal known as an Ewwok that reproduces following the rules below:
• An Ewwok dies six months after it is born. That is, if an Ewwok is born in month 0, it will die in month 6.
• An Ewwok gives birth to two Ewwoks every two months until it dies. That is, if an Ewwok is born in month 0, it will reproduce in months 2 and 4. It does not reproduce in month 6 or beyond.
• In each month, among all the Ewwoks that have been alive for exactly three months, there is one that dies. That is, if there are n (n > 0) Ewwoks that are born in month 0, one of them will die in month 3.
Given an integer initial representing the number of Ewwoks born in month 0, and an integer m representing a month, your task in this question is to write a program that calculates and returns the number of Ewwoks alive in month m.
For example, if there is 1 Ewwok born in month 0 (initial = 1):
• In • In • In • In • In • In • In • In • …
month 1, there is 1 Ewwok.
month 2, there are 3 Ewwoks (2 are born by the initial Ewwok).
month 3, there are 2 Ewwoks (the initial Ewwok dies).
month 4, there are 6 Ewwoks (4 are born).
month 5, there are 5 Ewwoks (1 of the Ewwoks born in month 2 dies).
month 6, there are 15 Ewwoks (10 are born).
month 7, there are 14 Ewwoks (1 of the Ewwoks born in month 4 dies).
month 8, there are 39 Ewwoks (the remaining Ewwok born in month 2 dies; 26 are born).
You may assume that initial >= 0 and m >= 0.
First sample session with the program:
Enter initial population of Ewwoks? 2
Find population in month? 8
Ewwok population in month 8 is 105
Second sample session with the program:
Enter initial population of Ewwoks? 5
Find population in month? 10
Ewwok population in month 10 is 825
Third sample session with the program:
Enter initial population of Ewwoks? 1
Find population in month? 48
Ewwok population in month 8 is 20424869889
Question 3 (6 marks): Dodgy Computer Credit!
The motto of Dodgy Computer Store is ”Buy now, pay later!” The store loans customers money to buy a product, and the customer must pay off the loan over time. The Dodgy Computer Store repayment plan has the following rules and definitions:
3

Purchase price
The initial cost of the product.
Down Payment
A one-off payment at the beginning of the loan, which is 12% of the purchase price.
Monthly Repayments
Repayments must be made every month. Repayments are fixed at 6% of the purchase price. Each month’s payment includes some of the original loan, and some interest. For example, if the purchase price is $100, then each monthly repayment will be $6, including interest.
Opening & Closing Balance
The size of the loan at the start of a month is referred to as the opening balance, and the size of the loan at the end of a month is the closing balance. For instance, if the closing balance in January is $10, then the opening balance in February is $10. (The opening/closing balance do not include interest.)
Interest
There is an annual interest rate of 15%, and interest is calculated and paid monthly. The amount of interest to repay each month is calculated as
interest = opening balance ∗ 0.15 12
Principal
The principal is the amount of the original loan repayed each month. In other words,
principal = repayment − interest
Write a program that takes the purchase price (a float) as input. The program must print a table, with appro- priate headers, of the payment schedule for the lifetime of the loan, not including the down payment. The columns of the table, and their widths, are as follows:
Month (7 spaces wide)
The month number, beginning from 1
Opening Bal (13 spaces wide)
The opening balance for the month
Interest (10 spaces wide)
The interest paid for the month
Principal (11 spaces wide)
The principal paid for the month
Repayment (11 spaces wide)
The total repayment for the month
Closing Bal (13 spaces wide)
The closing balance for the month
Notes:
1. You should round the closing balance and the interest to 2 decimal places when you calculate them each month.
2. The final repayment will be smaller than the other repayments (see the final month of the example tables below).
3. The monthly repayment must be at least $0.01, otherwise the loan might never be paid off!
4. Table entries are left-aligned, and every cell has one space padding on the left and right. If an entry in the table contains more digits than fit in the column, the column should expand to fit the number, along with one space padding on either side.
5. The table header will always be the same width, no matter how big the numbers in the table.
6. When you correctly implement the repayment plan, you will find that many (but not all) loans have a lifetime of 17 months. This is because Dodgy Computer Store offers customers a 17-month repay- ment plan. You do not need to explicitly implement this in your program.
4

Here’s an example of how your program should work:
Enter purchase price ($): 100
———————————————————————-
Month | Opening Bal | Interest | Principal | Repayment | Closing Bal
———————————————————————-
1 | 88.00
2 | 83.10
3 | 78.14
4 | 73.12
5 | 68.03
6 | 62.88
7 | 57.67
8 | 52.39
9 | 47.04
10 | 41.63
11 | 36.15
12 | 30.60
13 | 24.98
14 | 19.29
15 | 13.53
16 | 7.70
17 | 1.80
Here’s another example:
| 1.10
| 1.04
| 0.98
| 0.91
| 0.85
| 0.79
| 0.72
| 0.65
| 0.59
| 0.52
| 0.45
| 0.38
| 0.31
| 0.24
| 0.17
| 0.10
| 0.02
| 4.90
| 4.96
| 5.02
| 5.09
| 5.15
| 5.21
| 5.28
| 5.35
| 5.41
| 5.48
| 5.55
| 5.62
| 5.69
| 5.76
| 5.83
| 5.90
| 1.80
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 6.00
| 1.82
| 83.10
| 78.14
| 73.12
| 68.03
| 62.88
| 57.67
| 52.39
| 47.04
| 41.63
| 36.15
| 30.60
| 24.98
| 19.29
| 13.53
| 7.70
| 1.80
| 0.00
Enter purchase price ($): 12345678
———————————————————————-
Month | Opening Bal | Interest | Principal | Repayment | Closing Bal
———————————————————————-
1 | 10864196.64 | 135802.46 | 604938.22 | 740740.68 | 10259258.42
2 | 10259258.42 | 128240.73 | 612499.95 | 740740.68 | 9646758.47
3 | 9646758.47 | 120584.48 | 620156.20 | 740740.68 | 9026602.27
4 | 9026602.27 | 112832.53 | 627908.15 | 740740.68 | 8398694.12
5 | 8398694.12 | 104983.68 | 635757.00 | 740740.68 | 7762937.12
6 | 7762937.12 | 97036.71 | 643703.97 | 740740.68 | 7119233.15
7 | 7119233.15 | 88990.41 | 651750.27 | 740740.68 | 6467482.88
8 | 6467482.88 | 80843.54 | 659897.14 | 740740.68 | 5807585.74
9 | 5807585.74 | 72594.82 | 668145.86 | 740740.68 | 5139439.88
10 | 5139439.88 | 64243.00 | 676497.68 | 740740.68 | 4462942.20
11 | 4462942.20 | 55786.78 | 684953.90 | 740740.68 | 3777988.30
12 | 3777988.30 | 47224.85 | 693515.83 | 740740.68 | 3084472.47
13 | 3084472.47 | 38555.91 | 702184.77 | 740740.68 | 2382287.70
14 | 2382287.70 | 29778.60 | 710962.08 | 740740.68 | 1671325.62
15 | 1671325.62 | 20891.57 | 719849.11 | 740740.68 | 951476.51
16 | 951476.51 | 11893.46 | 728847.22 | 740740.68 | 222629.29
17 | 222629.29 | 2782.87 | 222629.29 | 225412.16 | 0.00
5

Question 4 (6 marks): Keeping Secrets
Write a program that encrypts text. The program requires the following user input:
1. the text to encrypt;
2. a positive integer primer. Valid primer values include: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25; 3. a second positive integer number
Each letter is shifted to the position n, where n is given by:
(primer ∗ position of each letter + number)
For example, if primer = 1, and number = 1, ’A’ will become ’B’ since
(1 ∗ 0[The alphabetic position of ’A’] + 1) = 1[The alphabetic position of ’B’].
In general, this setting will shift all alphabets by 1 place.
The program should ignore non-alphabetic characters. Encryption should return shifted alphabetic charac- ters of same case. You can assume primer and number are positive integers.
First sample session with the program:
Enter text: boohoo
Enter primer: 5
Enter positive integer: 8
naanaa
Second sample session with the program:
Enter text: Anything
Enter primer: 2
Enter positive integer: 3
Primer must be 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, or 25
End of assignment.
6


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持 Alipay WeChatPay PayPal等支付方式

E-mail: vipdue@outlook.com  微信号:vipdue


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论

电子邮件地址不会被公开。 必填项已用*标注