in Python Questions With Verified
Answers
CreateBaBsolutionBthatBacceptsBthreeBintegerBinputsBrepresentingBtheBnumberBofBtimesBanBemployee
BtravelsBtoBaBjobBsite.BOutputB theBtotalBdistanceB traveledBtoBtwoBdecimalBplacesBgivenBtheBfollowing
BmilesBperBemployeeBcommuteBtoBtheBjobBsite.BOutputBtheBtotalBdistanceBtraveledBtoBtwoBdecimalBp
lacesBgivenBtheBfollowingBmilesBperBemployeeBcommuteBtoBtheBjobBsite:
EmployeeBA:B15.62Bmiles
EmployeeBB:B41.85Bmiles
EmployeeBC:B32.67Bmiles
TheBsolutionBoutputBshouldBbeBinBtheBformat
Distance:Btotal_miles_traveledBmilesB-BAnswerB-BtravelsB=B{
"A":Bint(input()),
"B":Bint(input()),
"C":Bint(input())
}
miles_per_employeeB=B{"A":B15.62,B"B":41.85,B"C":B32.67}
total_miles_traveledB=Bsum(travels[employee]B*Bmiles_per_employee[employee]BforBemployeeBinBtra
vels)
print(f"Distance:B{total_miles_traveled:.2f}Bmiles")
CreateBaBsolutionBthatBacceptsBanBintegerBinputBrepresentingBanyBnumberBofBounces.BOutputBtheBco
nvertedBtotalBnumberBofBtons,Bpounds,BandBremainingBouncesBbasedBonBtheBinputBouncesBvalue.BTh
ereBareB16BouncesBinBaBpoundBandB2,000BpoundsBinBaBton.
TheBsolutionBoutputBshouldBbeBinBtheBformat
Tons:Bvalue_1BPounds:Bvalue_2BOunces:Bvalue_3B-BAnswerB-BouncesB=Bint(input())
value_1B=BouncesB//B(16B*B2000)
, value_2B=B(ouncesB%B(16B*B2000))B//B16
value_3B=BouncesB%B16
print(f"Tons:B{value_1}")
print(f"Pounds:B{value_2}")
print(f"Ounces:B{value_3}")
CreateBaBsolutionBthatBacceptsBanBintegerBinputBrepresentingBtheBindexBvalueBforBanyBanyBofBtheBfiv
eBelementsBinBtheBfollowingBlist:
various_data_typesB=B[516,B112.49,BTrue,B"meow",B("Western",B"Governors",B"University"),B{"apple":B
1,B"pear":B5}]
UsingBtheBbuilt-
inBfunctionBtype()BandBgettingBitsBnameBbyBusingBtheB.nameBattribute,BoutputBdataBtypeB(e.g.,Bint",B"
float",B"bool",B"str")BbasedBonBtheBinputBindexBvalueBofBtheBlistBelement.
TheBsolutionBoutputBshouldBbeBinBtheBformat
ElementBindex_value:Bdata_typeB-BAnswerB-Bindex_valueB=Bint(input())
data_typeB=Btype(various_data_types[index_value]).__name__
print(f"ElementB{index_value}:B{data_type}")
CreateBaBsolutionBthatBacceptsBanyBthreeBintegerBinputsBrepresentingBtheBbaseB(b1,Bb2)BandBheightB(
h)BmeasurementsBofBaBtrapezoidBinBmeters.BOutputBtheBexactBareaBofBtheBtrapezoidBinBsquareBmete
rsBasBaBfloatBvalue.BTheBexactBareaBofBaBtrapezoidBcanBbeBcalculatedBbyBfindingBtheBaverageBofBtheBt
woBbaseBmeasurements,BthenBmultiplyingBbyBtheBheightBmeasurement.
TrapezoidBAreaBFormula:AB=B[(b1B+Bb2)B/B2]B*Bh
TheBsolutionBoutputBshouldBbeBinBtheBformat
TrapezoidBarea:Barea_valueBsquareBmetersB-BAnswerB-Bb1B=Bint(input())
b2B=Bint(input())
hB=Bint(input())
area_valueB=Bfloat((b1B+Bb2)B/2)B*Bh
print(f"TrapezoidBarea:B{area_value}BsquareBmeters")
CreateBaBsolutionBthatBacceptsBfiveBintegerBinputs.BOutputBtheBsumBofBtheBfiveBinputsBthreeBtimes,Bc
onvertingBtheBinputsBtoBtheBrequestedBdataBtypeBpriorBtoBfindingBtheBsum.