ࡱ> /1.] bjbj 7x-\x-\ZZ 1333333$n zWWl11p0 E"  WWg" Z> : Programming Exercise Kilometer Conversion # Global constant for conversion KILOMETERS_TO_MILES = 0.6214 # main def def main(): # Local variables mykilometers = 0.0 # Variable to hold the distance in kilometers # Get distance in kilometers mykilometers = float(input("Enter the distance in kilometers: ")) # Print miles showMiles(mykilometers) # The showMiles function accepts kilometers as an argument # and prints the equivalent miles. def showMiles(kilometers): #Declare local variables miles = 0.0 miles = kilometers * KILOMETERS_TO_MILES print ("The conversion of", format(kilometers, '.2f'), "kilometers") print ("to miles is", format(miles, '.2f'), "miles.") # Call the main function. main() Programming Exercise: Calculate Calories Function # Global constants for calories CALORIES_FROM_FAT = 9 CALORIES_FROM_CARBS = 4 # main module def main(): # Local variables gramsFat = 0.0 gramsCarbs = 0.0 caloriesFat = 0.0 caloriesCarbs = 0.0 # Get grams fat. gramsFat = float(input('Enter the fat grams consumed: ')) # Get grams carbs. gramsCarbs = float(input('Enter the carbohydrate grams consumed: ')) # Calculate calories from fat. caloriesFat = gramsFat * CALORIES_FROM_FAT # Calculate calories from carbs. caloriesCarbs = gramsCarbs * CALORIES_FROM_CARBS # Print calories. showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs) # The showCarbs function accepts the number of grams of fat and # of carbs, as well as the calories from fat and from carbs, as # arguments and displays the resulting calories. def showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs): print('Grams of fat: ', format(gramsFat, '.2f')) print('Fat calories: ', format(caloriesFat, '.2f')) print('Grams of carbs: ', format(gramsCarbs, '.2f')) print('Carb calories: ', format(caloriesCarbs, '.2f')) # Call the main function. main() )*+ , - ô}l]h9uh OJQJ^JaJ h9uhqWCJOJQJ^JaJh9uhqWaJh9uhqWOJQJ\^JaJ#h9uhqWCJOJQJ\^JaJh9uhqW5CJaJh9uhqWOJQJ^JaJh9uhvJOJQJ^JaJh9uh CJ OJQJ^Jh9uh 5CJ h9uhj5CJ h9uhU5CJ *+Liju F K ] y z  % R gdvJ , - M c { |    V W n 1 f g gdqWgdvJg } ?pWgdvJgdqW51F:p>#V;0/ =!"#$% s2 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@_HmH nH sH tH N`N Normal*$1$ CJKHPJ_HaJmH sH tHDA D Default Paragraph FontViV  Table Normal :V 44 la (k (No List NN Heading x$CJOJPJQJ^JaJ6B6 Body Text x(/( List^JH""H Caption xx $6CJ]^JaJ.2. Index $^JPK![Content_Types].xmlN0EH-J@%ǎǢ|ș$زULTB l,3;rØJB+$G]7O٭VvnB`2ǃ,!"E3p#9GQd; H xuv 0F[,F᚜K sO'3w #vfSVbsؠyX p5veuw 1z@ l,i!b I jZ2|9L$Z15xl.(zm${d:\@'23œln$^-@^i?D&|#td!6lġB"&63yy@t!HjpU*yeXry3~{s:FXI O5Y[Y!}S˪.7bd|n]671. tn/w/+[t6}PsںsL. J;̊iN $AI)t2 Lmx:(}\-i*xQCJuWl'QyI@ھ m2DBAR4 w¢naQ`ԲɁ W=0#xBdT/.3-F>bYL%׭˓KK 6HhfPQ=h)GBms]_Ԡ'CZѨys v@c])h7Jهic?FS.NP$ e&\Ӏ+I "'%QÕ@c![paAV.9Hd<ӮHVX*%A{Yr Aբ pxSL9":3U5U NC(p%u@;[d`4)]t#9M4W=P5*f̰lk<_X-C wT%Ժ}B% Y,] A̠&oʰŨ; \lc`|,bUvPK! ѐ'theme/theme/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6 0_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!R%theme/theme/theme1.xmlPK-! ѐ' theme/theme/_rels/themeManager.xml.relsPK] $ g  8@0(  6 3 qtuxajkw$r|5BEOpst}~ CM{lpuxak|).V[~$r|5BAJps"([a33333333333333333333333333333333333)+)+  c "0m!Q59EGvJ&cK>#VM[5]`bGqe9uflL@CxpUCIjJqWg6@ @UnknownG*Ax Times New Roman5Symbol3. *Cx Arial?= *Cx Courier NewO.  k9Lucida Sans UnicodeG=  jMS Mincho-3 fg5. .[`)TahomaA$BCambria MathBAh/*/*P$&&!243QHP ?&cK!xx Programming Exercise 3-1 Tony GaddisOwnerOh+'0  4 @ L Xdlt|Programming Exercise 3-1 Tony GaddisNormalOwner2Microsoft Office Word@F#@euT@:@:&՜.+,0 hp  Pro Data Systems, Inc. Programming Exercise 3-1 Title  !"#$%'()*+,-0Root Entry F`21Table WordDocument7SummaryInformation(DocumentSummaryInformation8&CompObjr  F Microsoft Word 97-2003 Document MSWordDocWord.Document.89q