Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions bugged_dice_battle.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Import the random module to easily generate pseudo-random numbers
import random

# Define a function that simulates a dice battle between two players
def dice_battle():

# Generate random numbers between 1 and 6 for each player's die roll
die_1 = random.randint(1, 6)
die_2 = random.randint(1, 6)

# Compare the die rolls and return the result as a string
if die_1 > die_2:
return "Player 1 rolled a " + die_1 + " and Player 2 rolled a " + die_2 + ". Player 1 wins!"
return f"Player 1 rolled a {die_1} and Player 2 rolled a {die_2}. Player 1 wins!"
elif die_1 < die_2:
return "Player 1 rolled a " + die_1 + " and Player 2 rolled a " + die_2 + ". Player 2 wins!"
return f"Player 1 rolled a {die_1} and Player 2 rolled a {die_2}. Player 2 wins!"
else:
return "Player 1 rolled a " + die_1 + " and Player 2 rolled a " + die_2 + ". It's a tie!"
return f"Player 1 rolled a {die_1} and Player 2 rolled a {die_2}. It's a tie!"

print(dice_battle())
2 changes: 1 addition & 1 deletion bugged_factorial_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

# Loop from 1 to number (inclusive) and multiply factorial by each number
for i in range(1, number + 1):
factorial *= factorial * i
factorial *= i

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f


print(f"The factorial of {number} is {factorial}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c