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