• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

Intro To Python (Oa) Practice Questions With Correct Answers

Document preview thumbnail
Preview 2 out of 7 pages

INTRO TO PYTHON (OA) PRACTICE QUESTIONS WITH CORRECT ANSWERS

Content preview

INTRO TO PYTHON (OA) PRACTICE
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.

Document information

Uploaded on
June 11, 2025
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
lectbetty
4.3
(4)
Sold
25
Followers
0
Items
2462
Last sold
5 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions