diff --git a/05_howler/test-outs/sonnet-29.txt b/05_howler/test-outs/sonnet-29.txt index cf1faf554..5d52b2f6a 100644 --- a/05_howler/test-outs/sonnet-29.txt +++ b/05_howler/test-outs/sonnet-29.txt @@ -1,17 +1,17 @@ SONNET 29 WILLIAM SHAKESPEARE -WHEN, IN DISGRACE WITH FORTUNE AND MEN’S EYES, +WHEN, IN DISGRACE WITH FORTUNE AND MEN'S EYES, I ALL ALONE BEWEEP MY OUTCAST STATE, AND TROUBLE DEAF HEAVEN WITH MY BOOTLESS CRIES, AND LOOK UPON MYSELF AND CURSE MY FATE, WISHING ME LIKE TO ONE MORE RICH IN HOPE, FEATURED LIKE HIM, LIKE HIM WITH FRIENDS POSSESSED, -DESIRING THIS MAN’S ART AND THAT MAN’S SCOPE, +DESIRING THIS MAN'S ART AND THAT MAN'S SCOPE, WITH WHAT I MOST ENJOY CONTENTED LEAST; YET IN THESE THOUGHTS MYSELF ALMOST DESPISING, HAPLY I THINK ON THEE, AND THEN MY STATE, (LIKE TO THE LARK AT BREAK OF DAY ARISING -FROM SULLEN EARTH) SINGS HYMNS AT HEAVEN’S GATE; +FROM SULLEN EARTH) SINGS HYMNS AT HEAVEN'S GATE; FOR THY SWEET LOVE REMEMBERED SUCH WEALTH BRINGS THAT THEN I SCORN TO CHANGE MY STATE WITH KINGS. diff --git a/11_bottles_of_beer/test.py b/11_bottles_of_beer/test.py index d9487cc82..414b017dd 100755 --- a/11_bottles_of_beer/test.py +++ b/11_bottles_of_beer/test.py @@ -32,7 +32,7 @@ def test_usage(): def test_bad_int(): """Bad integer value""" - bad = random.randint(-10, 1) + bad = random.randint(-10, 0) rv, out = getstatusoutput(f'{prg} -n {bad}') assert rv != 0 assert re.search(f'--num "{bad}" must be greater than 0', out) diff --git a/22_itictactoe/solution1.py b/22_itictactoe/solution1.py index aa386f6ea..86d0f4e6e 100755 --- a/22_itictactoe/solution1.py +++ b/22_itictactoe/solution1.py @@ -28,16 +28,15 @@ def main() -> None: elif state.winner: print(f'{state.winner} has won!') break - - state = get_move(state) - - if state.quit: + elif state.quit: print('You lose, loser!') break elif state.draw: print("All right, we'll call it a draw.") break + state = get_move(state) + # -------------------------------------------------- def get_move(state: State) -> State: diff --git a/22_itictactoe/solution2_typed_dict.py b/22_itictactoe/solution2_typed_dict.py index e3ce00930..af30d412a 100755 --- a/22_itictactoe/solution2_typed_dict.py +++ b/22_itictactoe/solution2_typed_dict.py @@ -33,16 +33,15 @@ def main() -> None: elif state['winner']: print(f"{state['winner']} has won!") break - - state = get_move(state) - - if state['quit']: + elif state['quit']: print('You lose, loser!') break elif state['draw']: print('No winner.') break + state = get_move(state) + # -------------------------------------------------- def get_move(state: State) -> State: diff --git a/README.md b/README.md index b4debb0b7..8c5cefe1e 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,17 @@ http://tinypythonprojects.com/ There is a directory for each chapter of the book. Each directory contains a `test.py` program you can use with `pytest` to check that you have written the program correctly. I have included a short README to describe each exercise. -If you have problems writing code (or if you would like to support this project!), the book contains details about the skills you need. +If you have problems writing code, see my book for the skills you need. -The testing step is integral to writing and solving these challenges as well as to the methodology of the book. -I advocate a "test-driven development" mentality where we write tests _before_ we write code. -The tests should define what it means for a program to be correct, and then we write programs to satisfy the tests. +Testing is integral to writing and solving these challenges as well as to the methodology of the book. +I advocate for "test-driven development" where you write tests _before_ you write code. +The tests should define what it means for a program to be correct, and then you write programs to satisfy the tests. In this project, I've written all the tests for you, but I also encourage you to write your own functions and tests. You should run the test suite after every change to your program to ensure you are making progress! # Videos -I've been making videos for each chapter on my YouTube channel: +I made videos for each chapter on my YouTube channel: https://www.youtube.com/user/kyclark @@ -61,14 +61,9 @@ Here are the videos I've completed so far: # Forking GitHub repo -First use the GitHub interface to "fork" this repository into your own account. Then do `git clone` of *your* repository to get a local copy. Inside that checkout, do: - -```` -git remote add upstream https://github.com/kyclark/tiny_python_projects.git -```` - -This will allow you to `git pull upstream master` in order to get updates. When you create new files, `git add/commit/push` them to *your* repository. (Please do not create pull requests on *my* repository -- unless, of course, you have suggestions for improving my repo!). +If you like, you can use the GitHub interface to _fork_ this repository into your own account. +Then do `git clone` of *your* repository to get a local copy. # Copyright -© Ken Youens-Clark 2019-2020 +© Ken Youens-Clark 2019-2024 diff --git a/inputs/sonnet-29.txt b/inputs/sonnet-29.txt index 5e657e052..5faa7cb54 100644 --- a/inputs/sonnet-29.txt +++ b/inputs/sonnet-29.txt @@ -1,17 +1,17 @@ Sonnet 29 William Shakespeare -When, in disgrace with fortune and men’s eyes, +When, in disgrace with fortune and men's eyes, I all alone beweep my outcast state, And trouble deaf heaven with my bootless cries, And look upon myself and curse my fate, Wishing me like to one more rich in hope, Featured like him, like him with friends possessed, -Desiring this man’s art and that man’s scope, +Desiring this man's art and that man's scope, With what I most enjoy contented least; Yet in these thoughts myself almost despising, Haply I think on thee, and then my state, (Like to the lark at break of day arising -From sullen earth) sings hymns at heaven’s gate; +From sullen earth) sings hymns at heaven's gate; For thy sweet love remembered such wealth brings That then I scorn to change my state with kings.