From 0e73a0d1d9301ffd5179d895baf60d8899bf2d34 Mon Sep 17 00:00:00 2001 From: Ken Youens-Clark Date: Tue, 7 Dec 2021 19:10:02 -0700 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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