DEV Community

Cover image for Day 03 of My AI & Data Mastery Journey: From Python to Generative AI
Nitin-bhatt46
Nitin-bhatt46

Posted on

Day 03 of My AI & Data Mastery Journey: From Python to Generative AI

TODAY’S PROJECT

Project :- **
**Rock Paper Scissors Game

  1. Display game options and ask player for their choice: • "Type 0 for Rock" • "Type 1 for Paper" • "Type 2 for Scissors"
  2. Get the player’s input and store as user_input
  3. Randomly pick a number between 0 and 2 for the computer’s move, store as computer_input
  4. Associate the numbers with their respective game images (Rock, Paper, or Scissors) for display purposes
  5. Show what the computer chose by printing its game image
  6. Show what the user chose by printing their corresponding image
  7. If user_input is invalid (less than 0 or greater than 2), print "INVALID CHOICE, you lose"
  8. Otherwise, compare the choices and determine the winner: If user selected Rock and computer selected Scissors, user wins If user selected Scissors and computer selected Rock, user loses If both choices are the same, it’s a draw If computer’s number is less than user’s, user wins If computer’s number is greater than user’s, user loses
  9. Show the appropriate message based on who wins, loses, or if there is a draw

**Now it’s time for some hands-on practice.
👉 Are you ready for today’s learning challenge?”

🧠 CREATION QUESTIONS**

  1. Add a Scoreboard Feature Create a version of this game that: Lets the user play best of 5 rounds (i.e., whoever wins 3 rounds first wins the game). Displays the current score after each round (e.g., “User: 2 | Computer: 1”). At the end, print: 🏆 “You are the Champion!” if user wins 💻 “Computer Wins the Series!” if computer wins

**Debugging Questions

Debug Question 1:-**

elif computer_input < user_input:

print(game_image[user_input])

print("You WIN") elif computer_input > user_input:

print(game_image[user_input])

print("You LOST")

👉 This logic doesn’t always produce the right result (e.g., Rock vs Scissors fails).
Fix it so that the results follow actual Rock–Paper–Scissors rules.
(Hint: You must handle the circular rule — Rock beats Scissors even though 0 < 2.)

**Debugging 2

  1. Index Error Bug**

A student accidentally swapped the print order:

print("You chose", game_image[user_input])
print("Computer chose", game_image[computer_input])
But if the user enters an invalid input (like 5), this code crashes before the invalid check runs.
👉 Modify the code so that it does not crash and still prints “INVALID CHOICE, you lose”.

🎯 You’ve completed AI & Data Mastery Journey – 03

Topic: Starting with Python 🐍

📂 Code & Examples → GitHub (link in bio)

Top comments (0)