QUESTIONS WITH CORRECT ANSWERS
Create ba bsolution bthat baccepts bthree binteger binputs brepresenting bthe bnumber bof
btimes ban bemployee btravels bto ba bjob bsite. bOutput bthe btotal bdistance btraveled bto
btwo bdecimal bplaces bgiven bthe bfollowing bmiles bper bemployee bcommute bto bthe bjob
bsite. bOutput bthe btotal bdistance btraveled bto btwo bdecimal bplaces bgiven bthe bfollowing
bmiles bper bemployee bcommute bto bthe bjob bsite:
Employee bA: b15.62 bmiles
Employee bB: b41.85 bmiles
Employee bC: b32.67 bmiles
The bsolution boutput bshould bbe bin bthe bformat
Distance: btotal_miles_traveled b- bcorrect banswer✔✔commute b= b{
b'Employee bA': b15.62, b
b'Employee bB': b41.85, b
b'Employee bC': b32.67
}
travels b= b{
b'Employee bA': bint(input()), b
b'Employee bB': bint(input()), b
b'Employee bC': bint(input())
}
t_d_t b= bsum(commute[employee]*travels[employee] bfor bemployee bin btravels)
print(f'Distance: b{t_d_t:.2f} bmiles')
Create ba bPython bsolution bto bthe bfollowing btask. bEnsure bthat bthe bsolution bproduces
boutput bin bexactly bthe bsame bformat bshown bin bthe bsample(s) bbelow, bincluding
bcapitalization band bwhitespace.
Task:
Create ba bsolution bthat baccepts ban binteger binput brepresenting bany bnumber bof
bounces. bOutput bthe bconverted btotal bnumber bof btons, bpounds, band bremaining
bounces bbased bon bthe binput bounces bvalue. bThere bare b16 bounces bin ba bpound band
b2,000 bpounds bin ba bton.
The bsolution boutput bshould bbe bin bthe bformat
, Tons: bvalue_1 bPounds: bvalue_2 bOunces: bvalue_3 b- bcorrect banswer✔✔opp b= b16
top b= b2000
ounces b= bint(input())
tons b= bounces b// b(opp b* btop)
ro b= bounces b% b(opp b* btop)
pounds b= bro b// bopp
ro b%= bopp
print(f'Tons: b{tons}')
print(f'Pounds: b{pounds}')
print(f'Ounces: b{ro}')
Create ba bsolution bthat baccepts ban binteger binput brepresenting bthe bindex bvalue bfor
bany bany bof bthe bfive belements bin bthe bfollowing blist:
various_data_types b= b[516, b112.49, bTrue, b"meow", b("Western", b"Governors",
b"University"), b{"apple": b1, b"pear": b5}]
Using bthe bbuilt-in bfunction btype() band bgetting bits bname bby busing bthe b.name
battribute, boutput bdata btype b(e.g., bint", b"float", b"bool", b"str") bbased bon bthe binput
bindex bvalue bof bthe blist belement.
The bsolution boutput bshould bbe bin bthe bformat
Element bindex_value: bdata_type b- bcorrect banswer✔✔I_V b= bint(input())
if b-1 b<= bI_V b< blen(various_data_types):
belement b= bvarious_data_types b[I_V]
D_T_N b= bstr(type(element)).split("'")[1]
print(f' bElement b{I_V}: b{D_T_N}')
Create ba bsolution bthat baccepts bany bthree binteger binputs brepresenting bthe bbase
b(b1, bb2) band bheight b(h) bmeasurements bof ba btrapezoid bin bmeters. bOutput bthe
bexact barea bof bthe btrapezoid bin bsquare bmeters bas ba bfloat bvalue. bThe bexact barea
bof ba btrapezoid bcan bbe bcalculated bby bfinding bthe baverage bof bthe btwo bbase
bmeasurements, bthen bmultiplying bby bthe bheight bmeasurement.
Trapezoid bArea bFormula:A b= b[(b1 b+ bb2) b/ b2] b* bh
The bsolution boutput bshould bbe bin bthe bformat
Trapezoid barea: barea_value bsquare bmeters b- bcorrect banswer✔✔base_1 b=
bint(input())
base_2 b= bint(input())
height b= bint(input())
area b= b0.5 b* b(base_1 b+ bbase_2) b* bheight b
print(f'Trapezoid barea: b{area:.1f} bsquare bmeters')
Create ba bsolution bthat baccepts bfive binteger binputs. bOutput bthe bsum bof bthe bfive
binputs bthree btimes, bconverting bthe binputs bto bthe brequested bdata btype bprior bto
bfinding bthe bsum.