Implement a picker wheel in Python 3 using random
A very simple implementation in Python 3 using the random module
Intégrateur d'applications web open source expérimenté avec plus de 5 ans d'expertise le suivi d'intégration d'applications web Python 3 containerisées, assistance technique et résolution de problèmes, suivi et intégration de développements et tests. Initialement axé sur le support client et la résolution de problèmes, j'ai développé des compétences en suivi et réalisation d'intégrations techniques et développements en rapport avec la maintenance, le suivi, la mise à jour de la pile applicative, ou les exigences ou problèmes remontés par le client. Je recherche de nouvelles opportunités pour mettre à profit mes compétences techniques et interpersonnelles dans un environnement stimulant.
Discovering the diverse universe of craft beers can be both an exciting and overwhelming journey. But how do you choose which beer style to try next?
Enter: the Craft-Beer Picker Wheel.
import random
def picker_wheel(choices):
"""Select a random choice from a list."""
choice = random.choice(choices)
return choice
beer_types = [
"Bières IPA (India Pale Ale)",
"Bières Stout",
"Bières Sour Ale",
"Bières Saison/Farmhouse Ale",
"Bières Porte",
"Bières Lager",
"Bières Pilsner",
"Bières de Blé (Wheat Beers)",
]
selected_beer = picker_wheel(beer_types)
print("The picker wheel selected:", selected_beer)
Usage and result
user@computer % python3 craft_beer_picker_wheel.py
The picker wheel selected: Bières Sour Ale
In this script:
We import the
randommodule, which provides functionality for generating random numbers and making random choices.We define a function
picker_wheelthat takes a list of choices and returns a random choice from that list. It uses therandom.choicefunction to do this.We define a list of beer types.
We use the
picker_wheelfunction to select a random beer type.We print out the selected beer.