From 0a1216ad50b8a155311758fbf3a645ce6d09d77d Mon Sep 17 00:00:00 2001 From: Ken Youens-Clark Date: Tue, 5 Oct 2021 08:27:18 -0700 Subject: [PATCH 1/4] removing unicode characters --- 05_howler/test-outs/sonnet-29.txt | 6 +++--- inputs/sonnet-29.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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/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. From 0e73a0d1d9301ffd5179d895baf60d8899bf2d34 Mon Sep 17 00:00:00 2001 From: Ken Youens-Clark Date: Tue, 7 Dec 2021 19:10:02 -0700 Subject: [PATCH 2/4] fix for #16 --- 22_itictactoe/solution1.py | 7 +++---- 22_itictactoe/solution2_typed_dict.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) 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: From 026e185cd0e3b018a9afb722ab34a7ed8b1c04be Mon Sep 17 00:00:00 2001 From: Ken Youens-Clark Date: Wed, 6 Mar 2024 13:47:29 -0700 Subject: [PATCH 3/4] random.randint 2nd arg is inclusive, thanks Jeff Kuo! --- 11_bottles_of_beer/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From bcf4b241712f2cec1fe87e3599b4c82d3151b5ef Mon Sep 17 00:00:00 2001 From: Ken Youens-Clark Date: Thu, 7 Mar 2024 10:55:02 -0700 Subject: [PATCH 4/4] cleanup --- README.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) 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