Coder Social home page Coder Social logo

cash-5-lottery-random-number-generator's Introduction

Cash 5 Lottery Random Number Generator

A random number generator for the Cash Five lottery game. This script uses the 'customtkinter' GUI library, which is subsidiary of the standard tkinter library built-in Python. The script consists of a 'Generate Numbers' button that generates 5 random numbers between 1 and 41 and sorts them to be displayed in an entry text box.

Generating random numbers

   def generate_numbers(self):
       numbers = []
       while len(numbers) < 5:
           new_number = random.randint(1, 41)
           if new_number not in numbers:
               numbers.append(new_number)
       numbers.sort()
       return numbers

In addition, the application includes a save button labeled 'Save As' to store the 5 generated random numbers in a text file with using the filedialog library built-in Python.

    def save_file_as(self):
        filename = filedialog.asksaveasfilename(initialdir=r"C:\Documents", title="Save File As", defaultextension=".txt", filetypes=(('Text Documents,' '.txt*'), ("All Files", '*.*')))
        if filename:
            textcontent = str(self.entry_right.get())
            with open(filename, 'w+') as file:
                file.write(textcontent)
            print("File saved", filename)
        else:
            print("File save has been cancelled")

Requirements

  • customtkinter
  • filedialog
  • tkinter
  • random

Here's a video demo of the application

2023-01-18.12-54-23.mp4

License

MIT

cash-5-lottery-random-number-generator's People

Contributors

jmathtech avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.