Skip to content

import random.py Bug Report #3

@parsaCr766295

Description

@parsaCr766295

Here are the bugs I found in the code:

  1. The words used for the game choices are spelled inconsistently. In some places, "sang" is used, while in others, "sangg" is used. Similarly, "ghychi" is used in some places, while "gychi" is used in others. The code needs to be consistent in using one spelling for each choice.
  2. The game logic for determining the winner is incorrect. For example, the code states that if the computer chooses "sang" and the user chooses "ghychi", then the user wins (bkhti). However, in the traditional game of rock-paper-scissors, the user would lose in this scenario because paper (ghychi) is covered by rock (sang).
  3. The code contains duplicate conditions in the if-elif statements. For example, the condition where the computer chooses "sang" and the user chooses "kagaz" is repeated twice, which is unnecessary.
  4. The code does not handle the case where the user enters an invalid choice. If the user enters a choice that is not "sang", "kagaz", or "ghychi", then the code will simply print "mosavi", which means "draw" in Persian. Instead, the code should prompt the user to enter a valid choice.
  5. The code contains commented-out sections that are not used. These sections should either be removed or modified to be used in the game.

To fix these bugs, I would suggest the following changes:

  1. Choose one spelling for each game choice and use it consistently throughout the code.
  2. Correct the game logic for determining the winner based on the traditional rules of rock-paper-scissors.
  3. Remove duplicate conditions in the if-elif statements.
  4. Add error handling for invalid user choices.
  5. Decide whether to use the commented-out sections or remove them. If they are to be used, then modify them to work with the rest of the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions