PYTHON GPT3 - RANDOM SET 10 DISTINCTIVE POWERBALL NUMBERS

 


''' This python gui script (autogenerated by gpt3) creates a window with a button labeled "Generate Numbers". 

When the button is clicked, the generate_numbers function is called to generate the 10 sets of Powerball numbers, and the save_to_file function is called to save the numbers to a file. 

The file is named "powerball_[current date].txt", and the numbers are saved in the same directory as the script. 

The script also displays a message "Numbers saved to file!" 

on the gui window after the numbers are saved to the file. Please note that the above script is just a sample and you may need to modify it to suit your specific requirements. '''



import random

import tkinter as tk

from tkinter import filedialog

from datetime import datetime


def generate_numbers():

    numbers = []

    for i in range(10):

        powerball_set = []

        for j in range(5):

            powerball_set.append(random.randint(1, 69))

        powerball_set.sort()

        powerball_set.append(random.randint(1, 26))

        numbers.append(powerball_set)

    return numbers


def save_to_file():

    numbers = generate_numbers()

    date = datetime.now().strftime("%Y-%m-%d")

    file_name = f"powerball_{date}.txt"

    with open(file_name, "w") as file:

        for number_set in numbers:

            file.write(str(number_set) + "\n")

    file.close()

    result_label.config(text="Numbers saved to file!")


root = tk.Tk()

root.title("Powerball Number Generator")


generate_button = tk.Button(root, text="Generate Numbers", command=save_to_file)

generate_button.pack()


result_label = tk.Label(root, text="")

result_label.pack()


root.mainloop()


x

Comments

Popular posts from this blog

Understanding Variables in Python 3.0 for Beginners

First Steps: Your Initial Guide to Prompting ChatGPT

Evolución de los puntos de vista de los partidos políticos estadounidenses sobre Oriente Medio y las relaciones con Israel (1976 - 2023)