Python代写-ITP 449
时间:2021-03-12
SAMPLE Midterm Exam
ITP 449: Applications of Machine Learning
Fall 2020
Exam is done on student laptop using PyCharm. Open Book, Open notes, Open web. No communication
permitted.
Duration: 120 minutes
100 points
Submission
• For each problem, create a separate Python file. Name the file lastname_firstname_q#.py
• Create a Word file. Name the file lastname_firstname_exam1.py. Insert screenshots of the
output for each question in the Word file. Submit on Blackboard.
• Zip each Python file separately and submit on blackboard.
Problem 1:
You have been given the following code in Python. We want it to print a multiplication table. However,
due to syntax and other errors, it does not. Provide the correct code to get the desired output. (20
points).
print("Multiplication Table"\n)
num = input("Please enter a whole number")
symbol = "X"
for index = range(13):
product = index * num
msg = ""
if index < 10
msg = " "
msg = msg + index
output(msg, symbol, num, "=", product)
print(Math is fun!)
Desired Output
Multiplication Table

Please enter a whole number15
0 X 15 = 0
1 X 15 = 15
2 X 15 = 30
3 X 15 = 45
4 X 15 = 60
5 X 15 = 75
6 X 15 = 90
7 X 15 = 105
8 X 15 = 120
9 X 15 = 135
10 X 15 = 150
11 X 15 = 165
12 X 15 = 180
Math is fun!

Problem 2:
Write a program that prompts the user to enter a loan amount, interest rate, and number of years for a
car loan. Then it prints the monthly payment amount and the loan history. (30 points)
Loan amount:
30000
Interest Rate:
4
Years:
5
Your monthly payment is: $552.50

Here is your loan history.

Month Interest Balance

1 100.0 29547.5
2 98.49 29093.49
3 96.98 28637.97
4 95.46 28180.93
5 93.94 27722.37
6 92.41 27262.27
7 90.87 26800.65
8 89.34 26337.48
9 87.79 25872.78
10 86.24 25406.52
11 84.69 24938.71
12 83.13 24469.34
13 81.56 23998.4
14 79.99 23525.89
15 78.42 23051.81
16 76.84 22576.15
17 75.25 22098.91
18 73.66 21620.07
19 72.07 21139.64
20 70.47 20657.6
21 68.86 20173.96
22 67.25 19688.71
23 65.63 19201.84
24 64.01 18713.34
25 62.38 18223.22
26 60.74 17731.47
27 59.1 17238.07
28 57.46 16743.03
29 55.81 16246.34
30 54.15 15747.99
31 52.49 15247.99
32 50.83 14746.31
33 49.15 14242.97
34 47.48 13737.95
35 45.79 13231.24
36 44.1 12722.84
37 42.41 12212.75
38 40.71 11700.96
39 39.0 11187.46
40 37.29 10672.26
41 35.57 10155.33
42 33.85 9636.68
43 32.12 9116.3
44 30.39 8594.19
45 28.65 8070.34
46 26.9 7544.74
47 25.15 7017.39
48 23.39 6488.28
49 21.63 5957.41
50 19.86 5424.77
51 18.08 4890.35
52 16.3 4354.15
53 14.51 3816.16
54 12.72 3276.38
55 10.92 2734.81
56 9.12 2191.42
57 7.3 1646.23
58 5.49 1099.21
59 3.66 550.38
60 1.83 0
You will pay off the loan in 60 months
Problem 3:
Dataset extracted from the 1974 Motor Trend US magazine comprising fuel consumption and 10
aspects (attributes) of automobile design and performance for 32 automobiles is a famous
problem dataset used in machine learning and data analysis. We will use this dataset to perform
data abstraction, slicing, dicing and basic analysis using Pandas DataFrame, as taught in the class.

As you can observe in the cover page of the magazine, one of the main purpose of this data was
to assist decision making on which car to purchase during the 1973 Oil Crisis which began in
October 1973, when the members of the Organization of Arab Petroleum Exporting
Countries proclaimed an oil embargo and the affected countries were Canada, Japan,
the Netherlands, the United Kingdom and the United States and later extended
to Portugal, Rhodesia and South Africa.
By the end of the embargo in March 1974, the oil price had risen nearly 400%, from US$3
per barrel to nearly $12 globally; US prices were significantly higher. The embargo caused an oil
crisis, or "shock", with many short and long-term effects on global politics and the global
economy. It was famously called the “First Oil Shock”.
1. Create a DataFrame using the columns: Cylinders, Gear, Horsepower, Miles Per Gallon.
The row index labels are shown below (5)
2. Print the DataFrame. (5)

3. Print the dataframe in descending order of horsepower followed by ascending order
of Miles Per Gallon. (5)
4. Print the dataframe showing only 4 geared cars. (5)
5. Print the number of cars that have more than 20 Miles Per Gallon (5)
6. Now create a figure with 2x2 subplots. (5)
a. Subplot 1: Create a scatter plot of Horsepower vs Miles per gallon (5)
b. Subplot 2: Create a histogram of Cylinders (5)
c. Subplot 3: Create a column chart of Gear vs Car Name (5)
d. Subplot 4: Create a box plot of Horsepower (5)
























































































































































学霸联盟


essay、essay代写
essay、essay代写