diff --git a/.gitignore b/.gitignore index b300938..c742bdd 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,21 @@ code/09-working-with-files/.idea/vagrant.xml code/09-working-with-files/.idea/vcs.xml code/09-working-with-files/.idea/inspectionProfiles/profiles_settings.xml misc.xml +.idea/$CACHE_FILE$ +.idea/beginners-course.iml +.idea/modules.xml +.idea/vagrant.xml +.idea/vcs.xml +.idea/workspace.xml +.idea/inspectionProfiles/profiles_settings.xml +.idea/inspectionProfiles/Project_Default.xml +mkennedy.xml +code/08-problem-solving/tictactoe/.idea/tictactoe.iml +code/08-problem-solving/tictactoe/.idea/inspectionProfiles/Project_Default.xml +code/07-data-structures/rocks-game/rolls.json +code/09-working-with-files/rocks-game/requirements.txt +code/07-data-structures/simple_dict/.idea/simple_dict.iml +code/07-data-structures/simple_dict/.idea/inspectionProfiles/Project_Default.xml +workspace.xml + +.idea/ diff --git a/README.md b/README.md index 430b589..326ebdc 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,106 @@ ![](readme_resources/absolute-beginners.jpg) -Code samples and other handouts for our course. +Code samples and other handouts for our course. See the [**practice exercises**](/practices) for following along with the course. -See the [practice exercises](/practices). +## Course Summary + +Learning to program can be overwhelming. Concepts and facts come at you fast and most courses don't cover many of them at all or at a beginner's pace. **This is not most courses**. Python for absolute beginners is our premier course for beginning developers. We start at the very beginning, teaching you the big ideas and concepts covered in a CS 101 course. Then we move on to writing increasingly complex code and applications in Python. + + + +## What students are saying + +Python for Beginners was really well done, I have CodeAcademy and LinkedIn Learning (not bad mouthing them) but until I had your program I was really struggling. Course curriculum is very good. Thanks for putting this together. + + + +## What's this course about and how is it different? + +Most courses teach you the *facts* of programming and Python. Here is +how a loop is constructed. Here is how you test a condition and make +your program choose one path or another. Often they assume that you are +familiar with programming concepts such as data types, loops, functions, +and so on and that you just need to learn the details of how to do this in +Python. + +**This course is not most courses**. If you want ground up coverage of +software development using Python as the technology, this is your course! + +We spend significant time setting the stage to make sure you have +the big concepts clearly covered before diving into writing code. We +explicitly discuss how to approach problem solving when writing code +so that you don't have that *deer in the headlines* feeling. + +And the course content isn't just facts. You will see a lot of code +written before your eyes. That code isn't boring `foo()` this and +`bar()` that. **We build several fun and challenging games covering a wide +range of topics** that will be entirely relevant to your professional +projects. + +If you never had that formal computer science background but need to +jump into programming and Python, this course has your back. + + + +## What topics are covered + +In this course, you will: + +* Learn how to install Python and a proper editor to write code on your computer. +* See a quick, high-level overview of the *big ideas* of computer programming (e.g. data structures). +* Understand how Python executes a program and turns what you write into executable software. +* See how Python defines data types (integers, strings, etc.) and how to convert between them. +* Create interactive code that has a *conversation* with the user or data. +* Use functions to make your code more maintainable and reusable. +* Choose the right data structure to significantly improve the clarity and performance of your code. +* Create a basic AI / computer opponent for the games built during the course. +* Learn many problem solving techniques to help you dive right into writing code productively. +* See resources to help visualize connections between data created by your code. +* Work with multiple file formats to read and write data as our program runs. +* Use external libraries from [pypi.org](https://pypi.org). +* Add error handling to your application for a polished, reliable application. +* And lots more + +View the full [course outline](https://training.talkpython.fm/courses/explore_beginners/python-for-absolute-beginners#course_outline). + + + + +## Who is this course for? + +This course is for **anyone who wants to learn Python and computer programming**. If you haven't had a formal education in software development or have tried other courses and programming "didn't stick", then you are a great candidate student. + +The student requirements are quite light for this course. You'll need: + +* Basic typing skills +* Foundational computer experience (installing software etc.) +* A simple computer (macOS, Windows, or Linux) +* A desire to learn programming + +**Note**: All software used during this course, including editors, Python language, etc., are 100% free and open source. You won't have to buy anything to take the course. + + + + +## What games will we build? + +I believe it's important to learn programming in the context of something that feels plausible and real. We won't build a bunch of disconnected loops and other programming examples that don't relate back to real programs. We will build several fun games that cover meaningful content that any elementary +Python course would cover. + +1. **Guess the number of M&Ms in a jar** +2. **TIC-TAC-TOE** +3. **Rock-Paper-Scissors (3-way and 7-way)** +4. **A Connect4 clone** + + + +## The time to act is now + +If you've always wanted to learn programming and are considering Python as your gateway into that world, this is the course for you. We will fill in the concepts that would normally be covered in a CS 101 course without wasting your time taking semesters to cover what can be learned and practiced in a week or two. + +Dive into Python and become a software developer with this course. Join today! You've got nothing to lose. Every one of our courses comes with a 2-week money-back guarantee. + +Visit the [**course page to sign up**](https://training.talkpython.fm/courses/explore_beginners/python-for-absolute-beginners). diff --git a/code/05-interactive-code/m-n-m/.idea/.gitignore b/code/05-interactive-code/m-n-m/.idea/.gitignore deleted file mode 100644 index 5c98b42..0000000 --- a/code/05-interactive-code/m-n-m/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/code/05-interactive-code/m-n-m/.idea/.name b/code/05-interactive-code/m-n-m/.idea/.name deleted file mode 100644 index dcf0a95..0000000 --- a/code/05-interactive-code/m-n-m/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -M&M Guessing \ No newline at end of file diff --git a/code/05-interactive-code/m-n-m/.idea/M&M Guessing.iml b/code/05-interactive-code/m-n-m/.idea/M&M Guessing.iml deleted file mode 100644 index 4bb64fc..0000000 --- a/code/05-interactive-code/m-n-m/.idea/M&M Guessing.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/code/05-interactive-code/m-n-m/.idea/inspectionProfiles/profiles_settings.xml b/code/05-interactive-code/m-n-m/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/code/05-interactive-code/m-n-m/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/code/05-interactive-code/m-n-m/.idea/misc.xml b/code/05-interactive-code/m-n-m/.idea/misc.xml deleted file mode 100644 index a811725..0000000 --- a/code/05-interactive-code/m-n-m/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/code/05-interactive-code/m-n-m/.idea/modules.xml b/code/05-interactive-code/m-n-m/.idea/modules.xml deleted file mode 100644 index 4943257..0000000 --- a/code/05-interactive-code/m-n-m/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/code/05-interactive-code/m-n-m/.idea/vcs.xml b/code/05-interactive-code/m-n-m/.idea/vcs.xml deleted file mode 100644 index c2365ab..0000000 --- a/code/05-interactive-code/m-n-m/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/.gitignore b/code/06-organizing-code-with-functions/rocks-game/.idea/.gitignore deleted file mode 100644 index 5c98b42..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/.name b/code/06-organizing-code-with-functions/rocks-game/.idea/.name deleted file mode 100644 index 36f3bc5..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -RPS Functions \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/RPS Functions.iml b/code/06-organizing-code-with-functions/rocks-game/.idea/RPS Functions.iml deleted file mode 100644 index 4deaec0..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/RPS Functions.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/inspectionProfiles/profiles_settings.xml b/code/06-organizing-code-with-functions/rocks-game/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/misc.xml b/code/06-organizing-code-with-functions/rocks-game/.idea/misc.xml deleted file mode 100644 index 55b4798..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/modules.xml b/code/06-organizing-code-with-functions/rocks-game/.idea/modules.xml deleted file mode 100644 index 66e2a58..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/code/06-organizing-code-with-functions/rocks-game/.idea/vcs.xml b/code/06-organizing-code-with-functions/rocks-game/.idea/vcs.xml deleted file mode 100644 index c2365ab..0000000 --- a/code/06-organizing-code-with-functions/rocks-game/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/code/10-external-libraries/rocks-game/rpsgame.py b/code/10-external-libraries/rocks-game/rpsgame.py index 213097d..ece7085 100644 --- a/code/10-external-libraries/rocks-game/rpsgame.py +++ b/code/10-external-libraries/rocks-game/rpsgame.py @@ -1,8 +1,21 @@ +################################# +# +# NOTE TO WINDOWS USERS: Please see the following github issue +# if you find weird characters instead color from colorama: +# +# https://github.com/talkpython/python-for-absolute-beginners-course/issues/7 +# +# Apparently, even though it's supposed to adjust automatically, it doesn't always. +# We've added a test to force it to do so at the beginning of main(). +# + import datetime import random import json import os +import platform +import colorama from colorama import Fore from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter, Completer, Completion @@ -11,6 +24,10 @@ def main(): + # See comment at top of file. + if platform.system() == 'Windows': + colorama.init(convert=True) + print(Fore.WHITE) log("App starting up...") diff --git a/code/11-error-handling/rocks-game/rpsgame.py b/code/11-error-handling/rocks-game/rpsgame.py index c3448c1..39fcbf0 100644 --- a/code/11-error-handling/rocks-game/rpsgame.py +++ b/code/11-error-handling/rocks-game/rpsgame.py @@ -1,8 +1,10 @@ import datetime +import platform import random import json import os +import colorama from colorama import Fore rolls = {} @@ -10,7 +12,11 @@ def main(): try: - print(Fore.WHITE) + # See comment at top of the rpsgame.py in CHAPTER 10. + if platform.system() == 'Windows': + colorama.init(convert=True) + + print(Fore.LIGHTWHITE_EX) log("App starting up...") show_header() @@ -24,17 +30,17 @@ def main(): log("Game over.") except json.decoder.JSONDecodeError as je: print() - print(Fore.LIGHTRED_EX + "ERROR: The file rolls.json is invalid JSON." + Fore.WHITE) - print(Fore.LIGHTRED_EX + f"ERROR: {je}" + Fore.WHITE) + print(Fore.LIGHTRED_EX + "ERROR: The file rolls.json is invalid JSON." + Fore.LIGHTWHITE_EX) + print(Fore.LIGHTRED_EX + f"ERROR: {je}" + Fore.LIGHTWHITE_EX) except FileNotFoundError as fe: print() - print(Fore.LIGHTRED_EX + "ERROR: Rolls file not found" + Fore.WHITE) - print(Fore.LIGHTRED_EX + f"ERROR: {fe}" + Fore.WHITE) + print(Fore.LIGHTRED_EX + "ERROR: Rolls file not found" + Fore.LIGHTWHITE_EX) + print(Fore.LIGHTRED_EX + f"ERROR: {fe}" + Fore.LIGHTWHITE_EX) except KeyboardInterrupt: print() - print(Fore.LIGHTCYAN_EX + "You gotta run? Ok, cya next time!" + Fore.WHITE) + print(Fore.LIGHTCYAN_EX + "You gotta run? Ok, cya next time!" + Fore.LIGHTWHITE_EX) except Exception as x: - print(Fore.LIGHTRED_EX + f"Unknown error: {x}" + Fore.WHITE) + print(Fore.LIGHTRED_EX + f"Unknown error: {x}" + Fore.LIGHTWHITE_EX) def show_header(): @@ -43,7 +49,7 @@ def show_header(): print(" Rock Paper Scissors") print(" Error Handling Edition") print("---------------------------") - print(Fore.WHITE) + print(Fore.LIGHTWHITE_EX) def show_leaderboard(): @@ -80,13 +86,13 @@ def play_game(player_1, player_2): if not roll1: print(Fore.LIGHTRED_EX + "Try again!") - print(Fore.WHITE) + print(Fore.LIGHTWHITE_EX) continue log(f"Round: {player_1} roll {roll1} and {player_2} rolls {roll2}") print(Fore.YELLOW + f"{player_1} rolls {roll1}") print(Fore.LIGHTBLUE_EX + f"{player_2} rolls {roll2}") - print(Fore.WHITE) + print(Fore.LIGHTWHITE_EX) winner = check_for_winning_throw(player_1, player_2, roll1, roll2) @@ -97,7 +103,7 @@ def play_game(player_1, player_2): else: msg = f'{winner} takes the round!' fore = Fore.GREEN if winner == player_1 else Fore.LIGHTRED_EX - print(fore + msg + Fore.WHITE) + print(fore + msg + Fore.LIGHTWHITE_EX) log(msg) wins[winner] += 1 @@ -109,7 +115,7 @@ def play_game(player_1, player_2): overall_winner = find_winner(wins, wins.keys()) fore = Fore.GREEN if overall_winner == player_1 else Fore.LIGHTRED_EX msg = f"{overall_winner} wins the game!" - print(fore + msg + Fore.WHITE) + print(fore + msg + Fore.LIGHTWHITE_EX) log(msg) record_win(overall_winner) @@ -156,7 +162,7 @@ def get_roll(player_name, roll_names): return roll_names[selected_index] except ValueError as ve: - print(Fore.RED + f"Could not convert to integer: {ve}" + Fore.WHITE) + print(Fore.RED + f"Could not convert to integer: {ve}" + Fore.LIGHTWHITE_EX) return None diff --git a/practices/ch04_first_lines/readme.md b/practices/ch04_first_lines/readme.md index 7fbb3ba..65268ef 100644 --- a/practices/ch04_first_lines/readme.md +++ b/practices/ch04_first_lines/readme.md @@ -55,8 +55,8 @@ Data is converted to numerical types using the type name (int, float, etc). Here ```python text = '7.2' -whole_number = int(text) # value = 7 number = float(text) # value = 7.2 +whole_number = int(number) # value = 7 ``` ## Exercises diff --git a/practices/ch07_data_structures/readme.md b/practices/ch07_data_structures/readme.md index 95297aa..0d4486b 100644 --- a/practices/ch07_data_structures/readme.md +++ b/practices/ch07_data_structures/readme.md @@ -10,7 +10,7 @@ Remember, these are for your own benefit. Feel free to skip them if you don't fi ### Creating a static dictionary -You can create a dictionary a number of ways. How you do this depends on how much data is static and how much is dynamic as part of the program's execution. +You can create a dictionary in a number of ways. How you do this depends on how much data is static and how much is dynamic as part of the program's execution. ```python # Static data styles: diff --git a/solutions/readme.md b/solutions/readme.md new file mode 100644 index 0000000..6245c59 --- /dev/null +++ b/solutions/readme.md @@ -0,0 +1,15 @@ +# Solutions: Proceed with caution. + +We've decided to include the solutions to the practice exercises. Initially, the intention was to omit them. It can be frustrating. However, **it's working your way through that actually drives the learning**. It feels good to see the solution, but to make it really click, you have to make it your own and work your way through it. + +That said, a large number of students have requested that I add these and so here they are. + +But, I want to you be sure you want to go down this path. Ideally, this is a *check my solution* type of thing. So we have made the steps a little bit manual. To see the solution, you have to check out the `with_solutions` branch. They do no appear in the default `master` branch (this one). + +You can do this on GitHub by just using the branch dropdown like this: + +![](./resources/branches.png) + +Then you will see a solutions folder below this one. + +Best of luck on the course, Michael! \ No newline at end of file diff --git a/solutions/resources/branches.png b/solutions/resources/branches.png new file mode 100644 index 0000000..e7bdf0f Binary files /dev/null and b/solutions/resources/branches.png differ