You are Here:
Linux Lite 4.0 Final has been released. See the Release Announcements Section.




[ HELPFUL TIP ] Project - UK & EU Lottery killas / Open Source donation builders

Author (Read 1709 times)

0 Members and 1 Guest are viewing this topic.

 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
removed friendliness, it is off topic here Admin says.






UK lottery random number picker, showing the Python code, and the successful running of this in Linux Lite Terminal.

Here is the code -
Code: [Select]
from random import *
 lottochoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]

# Picks 6 lotto numbers from the choices
x = sample(lottochoices, 6)
print x

print ("You have Options - " "\nDonate a percentage of any wins to your favorite project" "\nDonate the stake instead to your favorite project")

Copy/paste this into a leafpad file in your Home Directory and name this file lot.py

To run the file do -
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)
Copy/paste or type in to your terminal

Code: [Select]
python lot.py
The output will be of the form shown in the above screenshot, that is 6 numbers randomly picked from the 59 as you would do on a lottery ticket in UK.
Then choose your options in real life (interactive)


EU Lottery picker  -



EU lottery screenshot, showing Python code and the successful running of this in Linux Lite terminal.
This will pick from the 50 numbers your 5 numbers.
It will also pick from the 12 numbers your 2 lucky star numbers.
It will also output text with lifestyle options (interactivity)

Here is the code -
Code: [Select]
from random import *
 
euchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]

luckystars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
 
# Picks 5 lotto numbers from the choices
x = sample(euchoices, 5)

# Picks your lucky stars
y = sample(luckystars, 2)   

print x
print y

print ("You have Options - " "\nDonate a percentage of any wins to your favorite project" "\nDonate the stake instead to your favorite project")

Copy/paste this into a leafpad file in your Home Directory and name this file eulot.py

To run the file do -
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)
Copy/paste or type in to your terminal


Code: [Select]
python eulot.py
I hope it was interesting to read.
Last Edit: May 23, 2018, 05:33:11 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 


Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #1 on: May 18, 2018, 08:45:33 AM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
remove not on topic to offer assistance in this thread.
Last Edit: May 23, 2018, 05:31:44 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #2 on: May 18, 2018, 02:20:14 PM »
 

Mart

  • Occasional Poster
  • **
  • 50
    Posts
  • Country: gb
  • Reputation: 12
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: Celeron(R) Dual-Core CPU T3000 @ 1.80GHz

  • MEMORY: 3Gb
bitsnpcs
 
Hope you don't mind but I managed to adapt your code to the UK Lotto game. It worked great.

Here's the adapted code:

Code: [Select]
from random import *
 
lottochoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]

bonusnumber = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
 
# Picks 6 lotto numbers from the choices
x = sample (lottochoices,  6)

# Picks your bonus numbers
y = sample (bonusnumber, 1)   

print x
print y

print ("You have Options - " "\nDonate a percentage of any wins to your favorite project" "\nDonate the stake instead to your favorite project")

This was great fun and my first attempt at coding.

So, thanks a lot. Or should I say -

Thanks a million!

Mart

UPDATE: For all those familiar with the UK Lotto game, did you spot the output mistake - the bonus number is not chosen by the game player but provides a winning combination/tier just below the jackpot prize. So ignore the generated bonus number and just play the first six generated numbers.

Can bitsnpcs or someone else come up with an improved code?



Last Edit: May 18, 2018, 02:43:03 PM by Mart
Still running 3.8 and lovin' it
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #3 on: May 18, 2018, 04:33:32 PM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
bitsnpcs
Can bitsnpcs or someone else come up with an improved code?

Yes the first code I posted lol , this is for the UK lotto and only picks the 6 numbers like the player needs to pick.
It doesn't pick a bonus number as the player doesn't pick this.

Edit - removed things not on topic
Last Edit: May 23, 2018, 05:31:02 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #4 on: May 18, 2018, 06:18:20 PM »
 

Mart

  • Occasional Poster
  • **
  • 50
    Posts
  • Country: gb
  • Reputation: 12
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: Celeron(R) Dual-Core CPU T3000 @ 1.80GHz

  • MEMORY: 3Gb
Hi bitsnpcs

Thank you for the reply.

Yes, in my enthusiasm I missed the most important bit about donating your stake or some future winnings to your favorite cause or project. Very inspiring.

You're obviously using the Spirit code not just the python code.

All the best to a fellow traveller.

Mart

Last Edit: May 18, 2018, 06:24:55 PM by Mart
Still running 3.8 and lovin' it
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #5 on: May 18, 2018, 06:24:40 PM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
Can bitsnpcs or someone else come up with an improved code?

For picking one number in the range 1 thru 59 do

Code: [Select]
import random

number = random.randint(1, 59)

print number

Save code to leafpad, with your chosen filename then run in terminal by

Code: [Select]
python filename.py

<snip> removed things below here not on topic
Last Edit: May 23, 2018, 05:21:32 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #6 on: May 18, 2018, 06:44:48 PM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
removed not on the topic


Last Edit: May 23, 2018, 05:21:59 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #7 on: May 18, 2018, 07:04:40 PM »
 

Mart

  • Occasional Poster
  • **
  • 50
    Posts
  • Country: gb
  • Reputation: 12
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: Celeron(R) Dual-Core CPU T3000 @ 1.80GHz

  • MEMORY: 3Gb
I'm glad you like the phrase - I'm a bit of a frustrated writer with a few scripts knocking about, but stories on a human scale are not trending at the moment.

Yes, I do find your efforts at trying to solve the coding problem interesting, but a little over my head for now.  But i will re-read your explanation to try to get a better understanding of it myself.

As they say,

'Fortune favors the prepared mind' 

so keep working on your solution.

All the best




Last Edit: May 18, 2018, 07:08:48 PM by Mart
Still running 3.8 and lovin' it
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #8 on: May 18, 2018, 07:55:54 PM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
removed not on topic, not to be aiding hijacking of my thread.

Last Edit: May 23, 2018, 05:22:26 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #9 on: May 19, 2018, 07:30:04 AM »
 

Mart

  • Occasional Poster
  • **
  • 50
    Posts
  • Country: gb
  • Reputation: 12
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: Celeron(R) Dual-Core CPU T3000 @ 1.80GHz

  • MEMORY: 3Gb
Hi bitsnpcs

The simplest way for me to explain what I meant by 'stories on a human scale' is to illustrate it with the following link of top box office Hollywood films by decade -

http://www.filmsite.org/boxoffice2.html

Just compare the 2000 and 2010 decades to the rest. You'll see that the most watched films of recent decades are mainly comic book and CGI created, obviously not possible until the digital age, but personally, in this respect, I'm a bit of an analogue type of guy, so to speak.

There's nothing wrong with comic book and CGI inspired films of course, I have enjoyed some of the earlier ones myself, but now this genre tends to dominate the field.

In contrast, I believe -

Variety is the spice of life

Perhaps we should start a members' 'favorite film' thread, like the music thread, but using film trailers.


Last Edit: May 19, 2018, 07:33:56 AM by Mart
Still running 3.8 and lovin' it
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #10 on: May 19, 2018, 08:12:32 AM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
removed not on topic, not to be aiding the hijacking of my thread.

Last Edit: May 23, 2018, 05:22:52 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #11 on: May 19, 2018, 08:35:25 AM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
Hello Mart,
I have done a new UK Lotto python script :) .
Its actions are like a combination of the initial idea, and the first posted version above.

It is still 4 lines long, but is less typing, it doesn't need all the numbers to be typed out.
I also added to the output text that it is the lotto numbers.
I have also added more comment lines in the code to explain better what each part is doing.



Screenshot of new UK Lotto number picker running in terminal on Linux Lite, and also showing code in Gedit.

Here is the code, I saved it to a Leafpad document in Home folder and name it next.py

Code: [Select]
# imports random function
import random

# labelling for lotto number output
print ("Your UK lotto numbers are - ")

# Picks 6 random numbers between 1 and 59
# range goes to 60 so that 59 is inclusive, 60 is not inclusive
# .sample does not duplicate numbers picked
# Outputs these 6 results in a list
print(random.sample(range(1, 60),6))

# interactivity - prints options
print ("You have Options - " "\nDonate a percentage of any wins to your favorite project" "\nDonate the stake instead to your favorite project")

To run this open your terminal by holding down Ctrl and Alt keys and pressing t (Ctrl+Alt+t) .
Then copy/paste or type into terminal -
Code: [Select]
python next.pythen press Enter key.


Side note - removed other linux topic not on topic in this thread.
Last Edit: May 23, 2018, 05:23:38 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #12 on: May 19, 2018, 08:56:39 AM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
Hello,
using the second version of the UK Lotto above I have redone the EuroMillions Python script.



EuroMillions new version with less typing, and improved comment lines, running on Linux Lite in Terminal and showing code in Gedit.
I save this to a Leafpad document in Home folder and named this eunext.py


Here is the code


Code: [Select]
# imports random function
import random

# labelling for lotto number output
print ("Your EuroMillions numbers are - ")

# Picks 5 random numbers between 1 and 50
# range goes to 51 so that 50 is inclusive, 51 is not inclusive
# .sample does not duplicate numbers picked
# Outputs these 5 results in a list
print(random.sample(range(1, 51),5))

print ("Your Lucky Stars are - ")

print(random.sample(range(1, 13),2))

# interactivity - prints options
print ("You have Options - " "\nDonate a percentage of any wins to your favorite project" "\nDonate the stake instead to your favorite project")

To run this open terminal by holding down Ctrl and Alt keys and pressing t (Ctrl+Alt+t)
Then copy/paste or type

Code: [Select]
python eunext.py
I hope you enjoyed reading this.
Last Edit: May 19, 2018, 09:15:03 AM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Re: Project - UK & EU Lottery killas / Open Source donation builders
« Reply #13 on: May 21, 2018, 04:57:36 PM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
Removed socially friendly infos above here to comply with, not on topic

Result at this stage is -

1/ producing the lotto numbers randomly as it is intended for.

2/ button click output is printing to terminal, not to my output box above button.Unsure what I am doing wrong in the code, I have tried pretty much every trial and error I can think of at this time, as just learning Python.
I will have another try at getting the numbers to appear in the output box, at a future time.

3/ the Donate button does nothing yet, I am unsure of the code to add for it to open the browser, I doubt this will be difficult so I leave it for last after fixing output.

Last Edit: May 28, 2018, 03:16:21 PM by bitsnpcs
I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 

Demo of UK Lotto killa v 1.0
« Reply #14 on: May 28, 2018, 03:35:44 PM »
 

bitsnpcs

  • Artist
  • Platinum Level Poster
  • **********
  • 2391
    Posts
  • Country: ie
  • Reputation: 249

  • Linux Lite: 3.2 64bit
Demo of Fully functioning






I have contract (retained and exclusivity).
Proprietor of commercial and retail buildings.
I use no computer in work, I am just a home user, at beginner/learning Linux stage.
Trying to join in with community and assist where it may be possible :)
 


Tags: python 
 


Linux Lite 4.0 Final has been released. See the Release Announcements Section.