update,
This commit is contained in:
BIN
max015/T06/T06/3.1.3.png
(Stored with Git LFS)
Normal file
BIN
max015/T06/T06/3.1.3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
25
max015/T06/T06/4_1_6.py
Normal file
25
max015/T06/T06/4_1_6.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#edit this cell to write the program
|
||||
|
||||
votes_file = open ('./report/votes.txt', 'r')
|
||||
results_file = open ('./report/results.txt', 'w')
|
||||
disney_vote = 0
|
||||
hotel_icon_vote = 0
|
||||
ocean_park_vote = 0
|
||||
|
||||
for s in votes_file:
|
||||
if s.strip() == 'Disney':
|
||||
disney_vote = disney_vote + 1
|
||||
if s.strip() == 'Hotel ICON' :
|
||||
hotel_icon_vote = hotel_icon_vote + 1
|
||||
if s.strip() == 'Ocean Park':
|
||||
ocean_park_vote = ocean_park_vote + 1
|
||||
|
||||
disney_output = 'Disney:%s\n' % disney_vote
|
||||
hotel_icon_output = 'Hotel ICON:%s\n' % hotel_icon_vote
|
||||
ocean_park_output = 'Ocean Park:%s\n' % ocean_park_vote
|
||||
output = disney_output + hotel_icon_output + ocean_park_output
|
||||
|
||||
results_file.write(output.strip())
|
||||
|
||||
results_file.close()
|
||||
votes_file.close()
|
24
max015/T06/T06/5_1_5.py
Normal file
24
max015/T06/T06/5_1_5.py
Normal file
@@ -0,0 +1,24 @@
|
||||
#edit this cell to write your code
|
||||
#Hint: (1) input the name of the input file
|
||||
# (2) define a file handle for the input file
|
||||
# (3) for each line of the file, extract the carrier id and shipping rate by using string's find function
|
||||
# and slice operation, and then update the variables that store the lowest shipping rate and its carrier id
|
||||
|
||||
lowest_rate = -1
|
||||
lowest_rate_carrier = ""
|
||||
|
||||
file_name = input("please enter a file name: ")
|
||||
|
||||
with open(file_name, 'r') as carrier_file:
|
||||
for s in carrier_file:
|
||||
if s != "-1":
|
||||
p = s.find(' ')
|
||||
rate = float(s[p+1:])
|
||||
carrier = s[0:p]
|
||||
if ( rate < lowest_rate or lowest_rate == -1):
|
||||
lowest_rate_carrier = carrier
|
||||
lowest_rate = rate
|
||||
|
||||
output = 'The lowest shipping rate is %s, ' % lowest_rate
|
||||
output1 = 'submitted by %s.' % lowest_rate_carrier
|
||||
print(output+ output1)
|
1712
max015/T06/T06/CDS1001T6Report.ipynb
Normal file
1712
max015/T06/T06/CDS1001T6Report.ipynb
Normal file
File diff suppressed because it is too large
Load Diff
3
max015/T06/T06/new_requests.txt
Normal file
3
max015/T06/T06/new_requests.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
APPLE 100
|
||||
APPLE 120
|
||||
APPLE 130
|
7
max015/T06/T06/report/carrier.txt
Normal file
7
max015/T06/T06/report/carrier.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
OOCL 130
|
||||
MMM 100
|
||||
NNN 110
|
||||
OOO 99
|
||||
PPP 80
|
||||
RRR 111
|
||||
-1
|
3
max015/T06/T06/report/results.txt
Normal file
3
max015/T06/T06/report/results.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Disney:3
|
||||
Hotel ICON:4
|
||||
Ocean Park:3
|
11
max015/T06/T06/report/votes.txt
Normal file
11
max015/T06/T06/report/votes.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
Disney
|
||||
Hotel ICON
|
||||
Hotel ICON
|
||||
Ocean Park
|
||||
Disney
|
||||
Hotel ICON
|
||||
Ocean Park
|
||||
Disney
|
||||
Ocean Park
|
||||
Hotel ICON
|
||||
-1
|
6
max015/T06/T06/requests.txt
Normal file
6
max015/T06/T06/requests.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
APPLE 100
|
||||
ORANGE 90
|
||||
BANANA 95
|
||||
APPLE 120
|
||||
APPLE 130
|
||||
BANANA 2 5
|
Reference in New Issue
Block a user