Page 1 of 1

Python: Powerball quick pick

Posted: Tue Nov 21, 2023 10:38 am
by hudatolah

Code: Select all

##powerball.py 
import random

def generate_powerball_numbers():
    # Generate 5 random main numbers (between 1 and 69) without duplicates
    main_numbers = random.sample(range(1, 70), 5)

    # Generate 1 random Powerball number (between 1 and 26)
    powerball_number = random.randint(1, 26)

    return sorted(main_numbers), powerball_number

# Call the function to generate the winning numbers
winning_numbers, powerball = generate_powerball_numbers()

# Print the results
print("Powerball Winning Numbers:", winning_numbers)
print("Powerball:", powerball)