File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6363- π [ Chapter 7 - Dictionaries & Sets] ( https://github.com/gitdagray/python-course/tree/main/lesson07 )
6464- π [ Chapter 8 - While Loops & For Loops] ( https://github.com/gitdagray/python-course/tree/main/lesson08 )
6565- π [ Chapter 9 - Functions] ( https://github.com/gitdagray/python-course/tree/main/lesson09 )
66+ - π [ Chapter 10 - Recursion] ( https://github.com/gitdagray/python-course/tree/main/lesson10 )
Original file line number Diff line number Diff line change 1+ value = "y"
2+ count = 0
3+
4+ while value :
5+ count += 1
6+ print (count )
7+ if (count == 5 ):
8+ break
9+ else :
10+ value = 0
11+ continue
Original file line number Diff line number Diff line change 1+
2+
3+ def add_one (num ):
4+
5+ if (num >= 9 ):
6+ return num + 1
7+
8+ total = num + 1
9+ print (total )
10+
11+ return add_one (total )
12+
13+
14+ mynewtotal = add_one (0 )
15+ print (mynewtotal )
Original file line number Diff line number Diff line change 1+ import sys
2+ import random
3+ from enum import Enum
4+
5+
6+ def play_rps ():
7+
8+ class RPS (Enum ):
9+ ROCK = 1
10+ PAPER = 2
11+ SCISSORS = 3
12+
13+ playerchoice = input (
14+ "\n Enter... \n 1 for Rock,\n 2 for Paper, or \n 3 for Scissors:\n \n " )
15+
16+ if playerchoice not in ["1" , "2" , "3" ]:
17+ print ("You must enter 1, 2, or 3." )
18+ return play_rps ()
19+
20+ player = int (playerchoice )
21+
22+ computerchoice = random .choice ("123" )
23+
24+ computer = int (computerchoice )
25+
26+ print ("\n You chose " + str (RPS (player )).replace ('RPS.' , '' ).title () + "." )
27+ print ("Python chose " + str (RPS (computer )
28+ ).replace ('RPS.' , '' ).title () + ".\n " )
29+
30+ if player == 1 and computer == 3 :
31+ print ("π You win!" )
32+ elif player == 2 and computer == 1 :
33+ print ("π You win!" )
34+ elif player == 3 and computer == 2 :
35+ print ("π You win!" )
36+ elif player == computer :
37+ print ("π² Tie game!" )
38+ else :
39+ print ("π Python wins!" )
40+
41+ print ("\n Play again?" )
42+
43+ while True :
44+ playagain = input ("\n Y for Yes or \n Q to Quit\n " )
45+ if playagain .lower () not in ["y" , "q" ]:
46+ continue
47+ else :
48+ break
49+
50+ if playagain .lower () == "y" :
51+ return play_rps ()
52+ else :
53+ print ("\n ππππ" )
54+ print ("Thank you for playing!\n " )
55+ sys .exit ("Bye! π" )
56+
57+
58+ play_rps ()
You canβt perform that action at this time.
0 commit comments