100% satisfaction guarantee Immediately available after payment Read online or as PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

INTRO TO PYTHON (OA) PRACTICE QUESTIONS WITH CORRECT ANSWERS

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
11-06-2025
Written in
2024/2025

INTRO TO PYTHON (OA) PRACTICE QUESTIONS WITH CORRECT ANSWERS

Institution
D335
Module
D335

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.

Written for

Institution
D335
Module
D335

Document information

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

Subjects

Get to know the seller

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 Harvard University
Follow You need to be logged in order to follow users or courses
Sold
23
Member since
1 year
Number of followers
0
Documents
2487
Last sold
2 months ago
Betty

Welcome to Bettys store, your reliable source for high-quality test banks and study materials drawn to help you stand out academically. We offer a broad range of resources including test banks, study guides, solution manuals, and other study materials, all dilligently curated to ensure accuracy and effectiveness. Our affordable, instantly accessible materials are complemented by excellent customer support, making your learning experience seamless and efficient. Trust Betty to be your friend in academic success.

Read more Read less
4.3

4 reviews

5
2
4
1
3
1
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions