-->ProgrammingInDigitalGames(11145) byFrutuosoSilva,2016-2017 Lab3–ConditionalstatementandReadinput 1. Exercise-conditionalstatement day = 30 if day < 10: print "We are in the beginning of the month!" if day > 20: print "We are in the ending of the month!" Trythecodeaboveandtestitwithdifferentvaluesoftheday.Complete theprogramtoidentifyexactlythemiddleofthemonth(i.e.,dayequalto 15). 2. Exercise-conditionalstatement day = 18 if day < 10: print "We are in the beginning of the month!" elif day > 20: print "We are in the ending of the month!" else: print "We are in the middle of the month!" Trythecodeaboveandtestitwithdifferentvaluesoftheday. 3. Exercise–usingvariablesandprinting # Here's some new strange stuff, remember type it exactly. days = "Mon Tue Wed Thu Fri Sat Sun" months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug \nSep\nOct\nNov\nDec" print "Here are the days of week: ", days print "Here are the months: \n", months print "\nescape single/double-quote inside string\n" tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm \\ a \\ cat." -->ProgrammingInDigitalGames(11145) byFrutuosoSilva,2016-2017 fat_cat = """ I'll do a list: \t* Cat food \t* Fishies \t* Catnip\n\t* Grass """ print tabby_cat print persian_cat print backslash_cat print fat_cat 4. Exercise–createaprogramtowritethedaysoftheweekandforagiven daybetween1…7,writeitinthefollowingway: Mon Tue Wed Thu Fri Sat Sun 4 Changetheprogramtowriteanerrormessageifthedayisnotbetween 1...7. 5. Exercise-Takesomekindofinputfromuser print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() print "So, you're %r old, %r tall and %r heavy." % ( age, height, weight) Changethepreviousprogramsfromexercises1and3usingtheinput fromuser.Seethedifferencebetweenraw_input()andinput(). 6. Exercise–Createaprogramtoverifyifanumberintegerisoddoreven. Theusermustintroducethenumber(usetheinput()function). 7. Exercise–Createaprogramthatgivenanumberofseconds(introduced byuser)calculatesthehours,minutesandseconds.Theprogrammust writeamessagelike: The S seconds correspond to: X Hours, Y minutes and Z seconds Changetheprogramtodisplayamessageifthesecondsintroduceddon't havehoursorminutes. -->ProgrammingInDigitalGames(11145) byFrutuosoSilva,2016-2017 8. Exercise–Createaprogramtocalculatethefinalscoreofaplayer,where thefinalscoreisthebasepointsmultipliedbytheplayerleveldividedby 100.Theusermustintroducethebasepointsandmustselectoneofthe levels2or5. 9. Exercise–Createaprogramthatreadthreevaluesofscores(X,Y,Z)and calculatetheaverage,themaximumandtheminimumscoreintroduced. 10. Exercise–Createaprogramthatreadtwonumbers(AandB)andverifies ifBismultipleofA.NotethatBmustbegreaterthanA,otherwisethe programmustinformtheuserwithaerrormessage.
© Copyright 2026 Paperzz