... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Hayden Walker 2019 |
2 | 2 |
|
3 | 3 |
This is a portfolio of some of my favourite programs that I wrote during the summer of 2019. |
4 |
- *The programs are arranged alphabetically |
|
4 |
+ *The programs are arranged alphabetically (By folder name, not by title) |
|
5 | 5 |
|
6 | 6 |
NOTE: The following dependencies are required in order to successfully run some of these programs. These dependencies are *not* included in the Python Standard Library. |
7 | 7 |
*Matplotlib plotting library (for the Collatz Conjecture program) |
... | ... |
@@ -64,6 +64,10 @@ Conway's Game of Life (22 August) [Requires Pygame] |
64 | 64 |
*PyGame |
65 | 65 |
*Rectangles |
66 | 66 |
*Conditionals |
67 |
+ *Iteration |
|
68 |
+ *Object-Oriented Programming |
|
69 |
+ *Functions |
|
70 |
+ *Methods |
|
67 | 71 |
*Game Loop |
68 | 72 |
|
69 | 73 |
Generates 100 squares that can each be either living or dead; each 1-second "generation," if a living square has less than two or more than three living neighbours, it will die from either underpopulation or crowding. If a dead square has exactly three living neighbours, it will become living, via reproduction. |
... | ... |
@@ -110,6 +114,15 @@ Pig Latin (19 July) |
110 | 114 |
|
111 | 115 |
Converts a word into "Pig Latin;" i.e. if the word begins with a vowel, it will add "ay" to the end, and if it begins with a consonant, it will move the first letter to the end of the word and then add "ay." |
112 | 116 |
------------------------------------------------------------------------------------------------------------ |
117 |
+Recursive Guessing Game (24 August) |
|
118 |
+ *Recursion |
|
119 |
+ *Conditionals |
|
120 |
+ *Math operators |
|
121 |
+ *Floor division |
|
122 |
+ *Addition |
|
123 |
+ |
|
124 |
+ The user chooses a number between 0 and 100 (unknown to the computer), and the computer will guess it. A light project that I included because of recursion. |
|
125 |
+------------------------------------------------------------------------------------------------------------ |
|
113 | 126 |
Monty Python's Python Soundboard (31 July) |
114 | 127 |
*Tkinter GUI Library |
115 | 128 |
*Buttons |
118 | 131 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+''' |
|
2 |
+24 August 2019 |
|
3 |
+The game guesses a number recursively |
|
4 |
+''' |
|
5 |
+ |
|
6 |
+def getnum(hi, lo, tries = 0): |
|
7 |
+ mid = (hi + lo) // 2 # Find the midpoint between the high and low numbers |
|
8 |
+ tries += 1 # Count up a try |
|
9 |
+ |
|
10 |
+ if input(f"Is the number {mid}? Y/N: ").lower() == "y": |
|
11 |
+ print(f"I have won! Guessed in {tries} tries.") |
|
12 |
+ return 0 |
|
13 |
+ else: |
|
14 |
+ hilo = input(f"Is the number less than or greater than {mid}? L/G: ") |
|
15 |
+ if hilo.lower() == "l": |
|
16 |
+ getnum(mid, lo, tries) # Set the current number as the high point |
|
17 |
+ elif hilo.lower() == "g": |
|
18 |
+ getnum(hi, mid, tries) # Set the current number as the low point |
|
19 |
+ else: |
|
20 |
+ print("ERR") |
|
21 |
+ |
|
22 |
+print("Choose a number between 0 and 100 for me to guess.") |
|
23 |
+getnum(100, 0) |