python代写-PM 02
时间:2021-10-22

10/21/21, 8:47 PM 02-quiz.ipynb - Colaboratory https://colab.research.google.com/drive/1Do_k42bT5uHKZkQkDqZ3jqA2DEnPU-iD?usp=sharing#printMode=true 1/6 October 19, 2021 Please enter your answers into this notebook in the places provided. This is an open-Internet examination. You may use any books and materials, and the entire internet - - as well as all of the class notebook and examples -- in answering these questions. But you may not communicate with other people in completing this notebook. Please do not share this notebook with others until after the exam window is closed on Sunday night. There are 5 questions. Please note In general, your answers may be tested against different data than you see in the notebook. The "correctness" of your answer includes criteria such as readability, comments. The number of points for a problem is unrelated to its degree of diculty. DS 205: Quiz 2 World war I lasted from July 28, 1914 – November 11, 1918. This question asks you to read the Python documentation on the date class and the timedelta class. Based on these two classes, answer the following: 1a. How many days did WW-I last? (10 points) You should include the rst date but do not include the last date in your calculation. 1b. What day of the week did WW-I begin? (10 points) 1. Duration of WW-I (20 points) # Example of timedelta from datetime import date d1 = date.fromisoformat('2020-02-01') d2 = date.fromisoformat('2020-03-01') td = (d2-d1) td.days # How many days did WW-I last? 10/21/21, 8:47 PM 02-quiz.ipynb - Colaboratory https://colab.research.google.com/drive/1Do_k42bT5uHKZkQkDqZ3jqA2DEnPU-iD?usp=sharing#printMode=true 2/6 # Fill in # What day of the week did WW-I begin? # Fill in About this sample invoice: 2. Invoice Problem 10/21/21, 8:47 PM 02-quiz.ipynb - Colaboratory https://colab.research.google.com/drive/1Do_k42bT5uHKZkQkDqZ3jqA2DEnPU-iD?usp=sharing#printMode=true 3/6 ...that represents an entry in the above invoice and contains attributes 'Date', 'Ref', 'Description' 'Amount' and 'Payment'. Write a class InvoiceItem ... (40 points) 10/21/21, 8:47 PM 02-quiz.ipynb - Colaboratory https://colab.research.google.com/drive/1Do_k42bT5uHKZkQkDqZ3jqA2DEnPU-iD?usp=sharing#printMode=true 4/6 (The column Amount Due from the invoice shown above is a calculated column and should not be part of InvoiceItem ) The constructor __init__() should accept string arguments. self.date is of type date . string is of the form 'mm.dd.yy'. If yy < 50, the year should be set to be in this century, i.e., 2000, 2001, … 2049. If yy >= 50, it should be set to be in the previous century, i.e., 1950, … 1999. (20 points) self.ref and self.description are strings. (5 points) self.amount and self.payment should be set to be of type float . (15 points) from datetime import date class InvoiceItem(): # fill in details ... def __init__(self, date, ref, description, amount, payment): self.date = # Fill in. The representation of date should be as a date object self.ref = ref self.description = description self.amount = # Fill in self.payment = # Fill in ... def __str__(self): return # Fill in item_2 = InvoiceItem("04.11.19", "SI10073", "Sale", "$400", "") print(item_2) # This item should print (without the leading '# ' on each line): # Date: April 11, 2019 # Ref: SI10073 # Description: Sale # Amount: $400 # Payment: -- item_1 = InvoiceItem("04.02.19", "SI10072", "Sale", "$250", "") item_2 = InvoiceItem("04.11.19", "SI10073", "Sale", "$400", "") item_3 = InvoiceItem("04.15.19", "DC18", "Payment", "", "-$100") item_4 = InvoiceItem("04.22.19", "CR20020", "Credit", "-$50", "") 3. Create InvoiceItems , and print a list of them (10 points) 10/21/21, 8:47 PM 02-quiz.ipynb - Colaboratory https://colab.research.google.com/drive/1Do_k42bT5uHKZkQkDqZ3jqA2DEnPU-iD?usp=sharing#printMode=true 5/6 print([item_1, item_2, item_3, item_4]) The Invoice class should have a self.opening_balance . contain a list of InvoiceItems . have an append (InvoiceItem) method which appends an InvoiceItem to the list. have an total_due method which calculates the total due. Verify that your implementation of the total_due method returns $600 for the above data when the opening balance is $100. 4. Write an Invoice class. (20 points) Find a suitable Python library to convert units of measurement. What is 300°K (Kelvin) in Fahrenheit? What is 4 US teaspoons in millilitres? 5. Unit Conversion The last step is to submit your work. Print it (CTRL-P) 1. Set Destination to Save as PDF 2. Set Pages to All. 3. Set Layout to Portrait. Set lename to 02-quiz.pdf . Submit to Gradescope, taking care to indicate the locations of each answer in the PDF. Save as PDF and submit to Gradescope 10/21/21, 8:47 PM 02-quiz.ipynb - Colaboratory https://colab.research.google.com/drive/1Do_k42bT5uHKZkQkDqZ3jqA2DEnPU-iD?usp=sharing#printMode=true 6/6




































































































学霸联盟


essay、essay代写