Docsity

D335 - Python Programming Lab Exercises, Exams of Programming Methodologies

Toggle sidebar
bg1
Pagei 1i ofi 5i
i
D335/i WGUi D335:i INTRODUCTIONi TOi
PROGRAMMINGi INi PYTHONi NEWESTi 2026i
ACTUALi EXAMi QUESTIONSi ANDi CORRECTi
ANSWERS
i
i
22.1i Lab:i Converti toi Secondsi
i
Writei ai programi thati readsi ini hours,i minutes,i andi secondsi asi input,i
andi outputsi thei timei ini secondsi only.i
i
22.2i Lab:i Converti fromi Secondsi
i
Peoplei findi iti easieri toi readi timei ini hours,i minutes,i andi secondsi
ratheri thani justi seconds.i
Writei ai programi thati readsi ini secondsi asi inputi andi outputsi thei timei
ini hours,i minutes,i andi seconds.i
i
22.3i Lab:i Pizzai Partyi
i
DO NOT COPY
pf3
pf4
pf5

Partial preview of the text

Download D335 - Python Programming Lab Exercises and more Exams Programming Methodologies in PDF only on Docsity!

i

D335/i WGUi D335:i INTRODUCTIONi TOi

PROGRAMMINGi INi PYTHONi NEWESTi 2026 i

ACTUALi EXAMi QUESTIONSi ANDi CORRECTi

ANSWERS

i i

22.1i Lab:i Converti toi Secondsi

i

Writei ai programi thati readsi ini hours,i minutes,i andi secondsi asi input,i

andi outputsi thei timei ini secondsi only.i

i

22.2i Lab:i Converti fromi Secondsi

i

Peoplei findi iti easieri toi readi timei ini hours,i minutes,i andi secondsi

ratheri thani justi seconds.i

Writei ai programi thati readsi ini secondsi asi inputi andi outputsi thei timei

ini hours,i minutes,i andi seconds.i

i

22.3i Lab:i Pizzai Partyi

i

DO NOT COPY

i

Giveni thei numberi ofi peoplei attendingi ai pizzai party,i outputi thei

numberi ofi neededi pizzasi andi totali cost.i Fori thei calculation,i

assumei thati peoplei eati 2 i slicesi oni averagei andi eachi pizzai hasi 12 i

slicesi andi costsi $14.95.i

i

22.4i Lab:i Hypotenusei

i

Giveni twoi numbersi thati representi thei lengthsi ofi ai righti triangle'si

legsi (sidesi adjacenti toi thei righti angle),i outputi thei lengthi ofi thei thirdi

sidei (i.e.i hypotenuse)i withi twoi digitsi afteri thei decimali point.i

i

22.5i Lab:i Areai ofi ai Trianglei

i

Usingi Heron'si formula,i youi cani calculatei thei areai ofi ai trianglei ifi youi

knowi thei lengthsi ofi alli threei sides.i Giveni thei lengthi ofi eachi sidei ofi ai

trianglei asi input,i calculatei thei areai ofi thei trianglei usingi Heron'si

formulai asi follows:i

si =i halfi ofi thei triangle'si perimeteri areai =i thei squarei rooti ofi s(s-

a)(s-b)(s-c),i wherei a,i b,i andi ci arei eachi sidesi ofi thei triangle.i

DO NOT COPY

i

Thei volumei andi areai ofi ai cylinderi arei calculatedi as:i

Volumei =i πr2hi

Areai =i 2 πrhi +i 2 πr2i

i

Giveni thei radiusi andi heighti ofi ai cylinderi asi floating-pointi numbers,i

outputi thei volumei andi areai ofi thei cylinder.i

i

22.9i LAB:i Warmi up:i Variables,i input,i andi typei conversioni

i

(1) Prompti thei useri toi inputi ani integeri betweeni 32 i andi 126,i ai float,i

ai character,i andi ai string,i storingi eachi intoi separatei variables.i

Then,i outputi thosei fouri valuesi oni ai singlei linei separatedi byi ai

space.i

(2) Extendi toi alsoi outputi ini reverse.i

(3) Extendi toi converti thei integeri toi ai characteri byi usingi thei 'chr()'i

function,i andi outputi thati character.i

i

22.10i LAB:i Cookingi Mesurementi Converteri

DO NOT COPY

i i i

DO NOT COPY