Python 1 TheYear2025 AllCodeClubsmustberegistered.Registeredclubsappearonthemapat codeclub.org.uk-ifyourclubisnotonthemapthenvisitjumpto.cc/18CpLPytofind outwhattodo. Introduction: Inthisprojectyou’llwriteaprogramtotellyouhowoldyou’llbeinthe year2025! ActivityChecklist FollowtheseINSTRUCTIONSonebyone TestyourProject ClickonthegreenflagtoTESTyourcode SaveyourProject MakesuretoSAVEyourworknow 1 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! Step1:Howmuch? ActivityChecklist 1. It’snotjusttextthatyoucanprintinPython,youcanalso printnumberstothescreen.Forexample,if8ofyourfriends eachgaveyou£2forasponsoredsilence,youcanusethis programtoseehowmuchmoneyyouraised: print(8*2) Thestar * intheprogramaboveisamultiplysign,sothe programshouldprinttheanswerto8x2. 2. Runtheprogramabove,andyoushouldseetheanswer: SaveYourProject 2 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! Challenge:Pocketmoney WriteaPythonprogramtocalculatehowmuchmoneyyou’d makeifyouwashed12cars,andcharged£2.50foreachcar. SaveYourProject Step2:Howold? ActivityChecklist 1. Witheverythingyou’velearntsofar,youshouldbeabletowrite aprogramtocalculatehowoldyou’llbeintheyear2025.The Pythonprogramtocalculateyourageshouldworklikethis: Asyoucansee,ifyouwerebornin2004,youcancalculate yourageintheyear2025bythecalculation 2025-2004 .So someonebornin2004willbe21yearsoldintheyear2025!If youweren’tbornin2004youcanchangethenumberinthe program. 3 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! SaveYourProject Challenge:Changingdates Changeyourprogramtofindouthowoldsomeonebornin1998 wouldbeintheyear2025.Howoldwillsomeonebornthisyear beintheyear2050? SaveYourProject Step3:Variables Whencompletingthechallengesabove,youhadtokeepchangingthenumbers intheprogramforpeopleofdifferentages,andfordifferentyearsinthe future.Itwouldbemucheasierifyoucouldasksomeonewhatyeartheywere born,andusetheanswerinyourcalculation.That’swhatvariablesarefor! ActivityChecklist 1. RunthisPythonprogram: print("Whatyearwereyouborn?") born=input() born=int(born) print(2025-born) Thisprogramwaitsforyoutotypeintheyearyouwereborn, andpressenter.Youshouldthenseehowoldyou’llbeinthe year2025: 4 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! Thisprogramusesthe input() functiontogettheuser’s inputfromthekeyboard,andstoreitinavariablecalled‘born’, sothatitcanbeusedlater.Youcanthinkofavariableasa box,whichcanbeusedtostoreimportantdata. Noticethatthevariable(thebox)hasbeennamed“born”,asit helpsyourememberwhatyou’restoringinsideit! Theline… 5 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! print(2025-born) …takeswhatevernumberhasbeenstoredinthe born variable awayfrom2025. Anythingthatistypedinfromthekeyboardisalwaysstoredas text,soyoualsohavetousethe int() functiontoturnthe user’sinputintoawholenumber(whichinprogrammingiscalled aninteger). 2. Youcanmakeyourprogrammucheasiertounderstand,by addingahelpfulmessagefortheuser,sotheyknowwhat you’reshowingthem.Changethelastlineofyourprogramto: print("In2025youwillbe",2025-born,"years old!") 3. Tryrunningyourprogramagain,toseehowthischangelooks. 4. Butwhystopthere?Youcouldalsouseanothervariableto 6 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! storetheanswerbeforeprintingitfortheuser.Trythis programout: SaveYourProject 7 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus! Challenge:Theyear3000! Yourprogramonlytellspeoplewhattheiragewillbeintheyear 2025.Whatifsomeonewantstoknowtheirageintheyear 2050?Ortheyear3000?Addanothervariabletoyour program,sothattheusercanfindouthowoldthey’llbeinany yeartheychoose. SaveYourProject Challenge:Yourageindogyears Writeaprogramtoasktheusertheirage,andthentellthem theirageindogyears!Youcancalculateaperson’sageindog yearsbymultiplyingtheirageby7. 8 TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
© Copyright 2024