Linux Lite Forums

Development => Coding => Topic started by: bitsnpcs on May 18, 2018, 10:49:40 AM

Title: Project - UK Thunderball killa / Open Source donation Builder
Post by: bitsnpcs on May 18, 2018, 10:49:40 AM
Hello,

adjusted Lotto killas so it works for the UK Thunderball draw.

 (https://preview.ibb.co/mfodty/thunder.png)

Screenshot of Thunderball number maker running on Linux Lite in terminal and its code in Gedit.
This will pick your 5 number choices from the 39, and then pick your 1 Thunderball number from the 14 numbers.
It will also give you real life choices to make (interactive)

Here is the code -

Code: [Select]
from random import *
 
thunderchoices = [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]

thunderball = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
 
# Picks 5 numbers from the choices
x = sample(thunderchoices, 5)

# Picks your thunderball
y = sample(thunderball, 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")

Copy/paste in to Leafpad document in Home folder and save as thunder.py


Hold down Ctrl and Alt then press t (Ctrl+Alt+t)
Copy/paste or type into terminal -

Code: [Select]
python thunder.py
Hope you enjoy reading this.
Title: Re: Project - UK Thunderball killa / Open Source donation Builder
Post by: bitsnpcs on May 19, 2018, 09:12:37 AM
Hello,

here is the new version of UK Thunderball picker, using less typing in code, and having more comment lines showing what it is doing.

(https://preview.ibb.co/fuMa88/thundernext.png)

Screenshot showing Thunderball picker running on Linux Lite in Terminal, and showing code in Gedit.

Here is the code -


Code: [Select]
# imports random function
import random

# labelling for thunderball output
print ("Your numbers are - ")

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

print ("Your Thunderball number is - ")

print(random.sample(range(1, 15),1))

# 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")

Copy paste the code into a Leafpad document in Home folder named thundernext.py

To run the code -
Open your terminal by holding down Ctrl + Alt then pressing t (Ctrl+Alt+t)
Copy paste or type in to your terminal


Code: [Select]
thundernext.py
Press Enter.

I hope you enjoyed reading this.