{"id":33,"date":"2025-09-21T18:46:17","date_gmt":"2025-09-21T22:46:17","guid":{"rendered":"https:\/\/wp.stgeorges.bc.ca\/deans\/?p=33"},"modified":"2025-09-22T23:02:07","modified_gmt":"2025-09-23T03:02:07","slug":"33","status":"publish","type":"post","link":"https:\/\/wp.stgeorges.bc.ca\/deans\/2025\/09\/21\/33\/","title":{"rendered":"Coding project"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<pre class=\"wp-block-preformatted\">Link to code: <a href=\"https:\/\/colab.research.google.com\/drive\/1zRVT20MhXBPmbU2OTtkjhJy_xtmiKGSi?usp=sharing\">https:\/\/colab.research.google.com\/drive\/1zRVT20MhXBPmbU2OTtkjhJy_xtmiKGSi?usp=sharing<\/a><\/pre>\n\n\n\n<p class=\"is-style-default has-large-font-size\">I am new to coding, so for my first project, I chose to create a simple Rock, Paper, Scissors game. This game was a good way for me to practice the basics of Python, such as functions, loops, and conditional statements. I also wanted to make sure the program was user-friendly, so I added clear messages, error checking, and a replay option to make it easy to use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"670\" src=\"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/09\/Screenshot-2025-09-21-at-12.48.29-1024x670.png\" alt=\"\" class=\"wp-image-36\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/09\/Screenshot-2025-09-21-at-12.48.29-1024x670.png 1024w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/09\/Screenshot-2025-09-21-at-12.48.29-300x196.png 300w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/09\/Screenshot-2025-09-21-at-12.48.29-768x503.png 768w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/09\/Screenshot-2025-09-21-at-12.48.29-1536x1005.png 1536w, https:\/\/wp.stgeorges.bc.ca\/deans\/wp-content\/uploads\/sites\/24\/2025\/09\/Screenshot-2025-09-21-at-12.48.29-2048x1340.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>-flow chart of the code<\/strong><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.1: FUNCTIONS<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code has-large-font-size\" style=\"border-style:none;border-width:0px\"><code>def play_rock_paper_scissors():<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">When the game begins, it prints a welcome message to introduce the game and let the player know they will be playing against the computer.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.2: INTRODUCTION AND LOOP<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code> print(\"   Let's Play Rock, Paper, Scissors!   \")\n    print(\"You will play against the computer.\")\n\n    while True:<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">When the game begins, it prints a welcome message to introduce the game and let the player know they will be playing against the computer.<br>Next, I set up a loop using <code><strong><kbd>while True<\/kbd><\/strong><\/code>, which repeats the game over and over until the player decides to stop. This way, the player can play multiple rounds without restarting the program.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.3: PLAYER CHOICE<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>        player_choice = input(\"Enter your choice (rock, paper, or scissors): \").lower()\n\n        if player_choice not in &#091;\"rock\", \"paper\", \"scissors\"]:\n\n        print(\"Invalid choice! Please type rock, paper, or scissors.\")\n\n        continue<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">The <code><strong>input()<\/strong><\/code> part pauses the game and waits for the player to type something. The program asks the player to type <strong>rock, paper, or scissors<\/strong>. I added <code><strong><kbd>.lower()<\/kbd><\/strong><\/code> so it works even if the player types capital letters like \u201cRock.\u201d <br>If the player types something invalid (like \u201cbanana\u201d), the program prints a warning and restarts the round. This prevents the game from crashing and keeps it friendly.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.4:COMPUTER CHOICE<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>        options = &#091;\"rock\", \"paper\", \"scissors\"]\n        computer_choice = random.choice(options)<\/code><\/pre>\n\n\n\n<p>Here, <code>options<\/code> is a list that stores the three possible choices. <code>random.choice(options)<\/code> picks one of them randomly. This makes the computer\u2019s choice fair and unpredictable.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.5: DISPLAYING CHOICES<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>    print(f\"You chose: {player_choice}\")\n    print(f\"The computer chose: {computer_choice}\")<\/code><\/pre>\n\n\n\n<p>These lines show the player what they chose and what the computer chose, so the player can clearly see both sides before the winner is announced.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.6: DECIDING THE WINNER<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>        if player_choice == computer_choice:\n            print(\"It's a tie! \ud83e\udd1d\")<\/code><\/pre>\n\n\n\n<p>The if statement checks a condition. If it\u2019s true, Python runs the code inside that block. This line checks if the player and the computer chose the same thing. If they did, it prints \u201cIt\u2019s a tie!\u201d If they didn\u2019t, Python moves to the next check.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>elif (player_choice == \"rock\" and computer_choice == \"scissors\") or \\\n             (player_choice == \"scissors\" and computer_choice == \"paper\") or \\\n             (player_choice == \"paper\" and computer_choice == \"rock\"):\n            print(\"You win! \ud83c\udf89\")<\/code><\/pre>\n\n\n\n<p><br><code>elif<\/code> stands for \u201celse if.\u201d It gives <strong>another condition to check if the previous <code>if<\/code> (or another <code>elif<\/code>) was false<\/strong>.<br>This line is checked only if the if condition wasn\u2019t true (so it wasn\u2019t a tie). The program looks at all the situations where the player would win. If any of these are true, it prints \u201cYou win!\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        else:\n            print(\"The computer wins! \ud83d\udcbb\")<\/code><\/pre>\n\n\n\n<p><br>The <code>else<\/code> statement is the <strong>catch-all<\/strong>. It runs only if none of the previous <code>if<\/code> or <code>elif<\/code> conditions were true.<br>This means if it wasn\u2019t a tie (<code>if<\/code>) and the player didn\u2019t win (<code>elif<\/code>), then the computer must have won. It doesn\u2019t need a condition because it automatically handles all remaining possibilities.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.7: PLAY AGAIN OPTION<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>        play_again = input(\"Do you want to play again? (yes\/no): \").lower()\n\n        if play_again != \"yes\":\n            break<\/code><\/pre>\n\n\n\n<p>The first line asks for input and converts it to lowercase so that \u201cYes\u201d or \u201cYES\u201d also works. The second line checks if the player typed anything other than \u201cyes.\u201d If they did, the <code>break<\/code> command stops the loop and ends the game.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.8: ENDING THE GAME<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>    print(\"Thanks for playing! Goodbye!\")<\/code><\/pre>\n\n\n\n<p>When the player decides to stop, the program prints a goodbye message to signal the end of the game.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>PT.9: RUNNING THE FUNCTION<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>play_rock_paper_scissors()<\/code><\/pre>\n\n\n\n<p>This line is important because it actually starts the game; without it, Python would just know the instructions inside the function but would never run them, so the player wouldn\u2019t see or play the game.<br><br><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\"><strong>Reflection<\/strong>:<\/h1>\n\n\n\n<p>In summary, I think I did a great job on this project. Even though it is a simple game, it is fun and interactive, and I am proud of creating it. This project helped me practice basic coding skills like functions, loops, variables, and conditional statements, and it taught me how to make a program user-friendly and responsive to input. It gives me confidence as a beginner in coding.<\/p>\n\n\n\n<div class=\"wp-block-buttons has-custom-font-size has-xx-large-font-size is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-a89b3969 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-text-align-center wp-element-button\" href=\"https:\/\/docs.google.com\/document\/d\/18RNrX4mg-fsfkecsziBj15vhV2SwAOeFoa_WT2tIrDo\/edit?tab=t.0\" style=\"border-width:16px\"><strong>GEMENI<\/strong> CONVO<\/a><\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Link to code: https:\/\/colab.research.google.com\/drive\/1zRVT20MhXBPmbU2OTtkjhJy_xtmiKGSi?usp=sharing I am new to coding, so for my first project, I chose to create a simple Rock, Paper, Scissors game. This game was a good way for me to practice the basics of Python, such as functions, loops, and conditional statements. I also wanted to make sure the program was user-friendly, [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":12,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":65,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/posts\/33\/revisions\/65"}],"wp:attachment":[{"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/deans\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}