1.Create BGa BGsolution BGthat BGaccepts BGthree BGinteger BGinputs BGrepresenting
BGthe BGnumber BGof BGtimes BGan BGemployee BGtravels BGto BGa BGjob BGsite. BGOutput
BGthe BGtotal BGdistance BGtraveled BGto BGtwo BGdecimal BGplaces BGgiven BGthe
BGfollowing BGmiles BGper BGemployee BGcommute BGto BGthe BGjob BGsite. BGOutput
BGthe BGtotal BGdistance BGtraveled BGto BGtwo BGdecimal BGplaces BGgiven BGthe
BGfollowing BGmiles BGper BGemployee BGcommute BGto BGthe BGjob BGsite:
Employee BGA: BG15.62
BGmiles BGEmployee BGB:
BG41.85 BGmiles
Employee BGC: BG32.67 BGmiles: BGtimes_traveledA BG=
BGint(input()) BGtimes_traveledB BG= BGint(input())
times_traveledC BG= BGint(input())
BGemployeeA BG= BG15.62 BG#miles
BGemployeeB BG= BG41.85 BG#miles
BGemployeeC BG= BG32.67 BG#miles
distance_traveledA BG= BGtimes_traveledA BG*
BGemployeeA BGdistance_traveledB BG=
BGtimes_traveledB BG* BGemployeeB
BGdistance_traveledC BG= BGtimes_traveledC BG*
BGemployeeC
total_miles_traveled BG= BGdistance_traveledA BG+ BGdistance_traveledB
BG+ BGdistance_trav- BGeledC
print('Distance: BG{:.2f} BGmiles'.format(total_miles_traveled))
1
BG/
, 2.Create BGa BGsolution BGthat BGaccepts BGan BGinput BGidentifying BGthe BGname BGof
BGa BGtext BGfile, BGfor BGexample, BG"WordTextFile1.txt". BGEach BGtext BGfile BGcontains
BGthree BGrows BGwith BGone BGword BGper BGrow. BGUsing BGthe BGopen() BGfunction
BGand BGwrite() BGand BGread() BGmethods, BGinteract BGwith BGthe BGinput BGtext BGfile
BGto BGwrite BGa BGnew BGsentence BGstring BGcomposed BGof BGthe BGthree BGexisting
BGwords BGto BGthe BGend BGof BGthe BGfile BGcontents BGon BGa BGnew BGline. BGOutput
BGthe BGnew BGfile BGcontents.: BGfile_name BG= BGinput()
with BGopen(file_name, BG'r') BGas BGf:
word1 BG=
BGstr(f.readline()).strip()
BGword2 BG=
BGstr(f.readline()).strip()
BGword3 BG=
BGstr(f.readline()).strip()
f BG= BGopen(file_name,
BG'r') BGlines BG=
BGf.read().splitlines()
BGlines BG= BG'
BG'.join(lines) BGf.close()
print(f'{word1}\n{word2}\n{word3}\n{lines}')
3.Create BGa BGsolution BGthat BGaccepts BGan BGinteger BGinput BGrepresenting
BGany BGnumber BGof BGounces. BGOutput BGthe BGconverted BGtotal BGnumber BGof
BGtons, BGpounds, BGand BGremaining BGounces BGbased BGon BGthe BGinput BGounces
BGvalue. BGThere BGare BG16 BGounces BGin BGa BGpound BGand BG2,000 BGpounds BGin BGa
BGton.: BGounces_per_pound BG= BG16
2
BG/