1.
Guess the Random Number
import random
number = [Link](1, 10)
guess = int(input("Guess a number between 1 and 10: "))
if guess == number:
print("Correct!")
else:
print(f"Wrong! The correct number was {number}")
2. Random Choice from User Input
import random
items = input("Enter items separated by commas: ").split(",")
choice = [Link](items)
print(f"Randomly selected item: {[Link]()}")
3. Generate a Random Password
import random
characters = input("Enter characters to use in password: ")
length = int(input("Enter desired password length: "))
password = ''.join([Link](characters) for _ in range(length))
print(f"Generated password: {password}")
4. Shuffle a List of Names
import random
names = input("Enter names separated by commas: ").split(",")
[Link](names)
print("Shuffled names:", ", ".join([Link]() for name in names))
5. Simulate Dice Rolls
import random
sides = int(input("Enter number of sides on the dice: "))
rolls = int(input("Enter number of times to roll: "))
for i in range(rolls):
print(f"Roll {i+1}: {[Link](1, sides)}")
6. Random Lottery Number Generator
import random
count = int(input("How many lottery numbers to generate? "))
max_number = int(input("Maximum number allowed: "))
numbers = [Link](range(1, max_number + 1), count)
print("Lottery numbers:", numbers)
7. Yes or No Predictor
import random
input("Ask your Yes/No question: ")
print([Link](["Yes", "No"]))
8. Random Quote Picker
import random
quotes = input("Enter quotes separated by semicolons: ").split(";")
print("Random Quote:", [Link](quotes).strip())
9. Simple Math Quiz
import random
a = [Link](1, 10)
b = [Link](1, 10)
answer = int(input(f"What is {a} + {b}? "))
if answer == a + b:
print("Correct!")
else:
print(f"Wrong! The correct answer is {a + b}")
10. Random Seating Arrangement
import random
names = input("Enter names separated by commas: ").split(",")
[Link](names)
for i, name in enumerate(names, 1):
print(f"Seat {i}: {[Link]()}")
11. Generate a Random Integer Between 1 and 100
import random
print("Random number between 1 and 100:", [Link](1, 100))
12. Shuffle a Deck of Cards
import random
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']
deck = [f"{rank} of {suit}" for suit in suits for rank in ranks]
[Link](deck)
print("Shuffled deck:", deck)
13. Flip a Coin
import random
print("Coin flip result:", [Link](["Heads", "Tails"]))
14. Roll Two Dice and Show Total
import random
die1 = [Link](1, 6)
die2 = [Link](1, 6)
print(f"Die 1: {die1}, Die 2: {die2}, Total: {die1 + die2}")
15. Randomly Pick a Team Leader
import random
names = input("Enter team member names separated by commas: ").split(",")
leader = [Link](names)
print(f"Team leader: {[Link]()}")