Skip to content

Commit b5ae1da

Browse files
committed
Add bugged Python programs
1 parent 129e67f commit b5ae1da

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

bugged_dice_battle.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Import the random module to easily generate pseudo-random numbers
2+
import random
3+
4+
# Define a function that simulates a dice battle between two players
5+
def dice_battle():
6+
7+
# Generate random numbers between 1 and 6 for each player's die roll
8+
die_1 = random.randint(1, 6)
9+
die_2 = random.randint(1, 6)
10+
11+
# Compare the die rolls and return the result as a string
12+
if die_1 > die_2:
13+
return "Player 1 rolled a " + die_1 + " and Player 2 rolled a " + die_2 + ". Player 1 wins!"
14+
elif die_1 < die_2:
15+
return "Player 1 rolled a " + die_1 + " and Player 2 rolled a " + die_2 + ". Player 2 wins!"
16+
else:
17+
return "Player 1 rolled a " + die_1 + " and Player 2 rolled a " + die_2 + ". It's a tie!"
18+
19+
print(dice_battle())

bugged_factorial_finder.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Initialize the factorial result to 1
2+
factorial = 1
3+
4+
# Initialize the input number to 6
5+
number = 6
6+
7+
# Loop from 1 to number (inclusive) and multiply factorial by each number
8+
for i in range(1, number + 1):
9+
factorial *= factorial * i
10+
11+
print(f"The factorial of {number} is {factorial}")

0 commit comments

Comments
 (0)