When teaching computing science, I sometimes need to create arbitrary samples of data for demonstrating various algorithms, for instance sorting algorithms.
I would like to get an easy way of generating lists of (random word, random value)
. If I need ~10 such tuples, I can hardcode (names, value)
tuples. But if I need ~50 such tuples, I can't do that.
I tried using ad-hoc function generating alternate vowel and consonant string, but I noticed that many students would focus on this function rather than on the main algorithm, asking what is the purpose of such or such line of code, and spending most of the time on that ad-hoc function.
I don't encounter such an issue when importing some function because the module is like a black box for them.
Thus I wonder if you could figure out some module in standard Anaconda distributions (students should not have to install anything more) that could lead to an easy to type one-liner such as
from XXX import YYY
from random import random, randrange
L = [ ( YYY(random()), randrange(0, 100)) for _ in range(50) ]
where YYY(random())
or any other syntax would result in some more or less natural language sounding string.
I don't ask for existing words, since I usually claim they are some names of people, but I would rather get tabati
than xwyaer
. Of course, if you are aware of some hidden gem in scipy
containing hardcoded names of towns or whatever, it would be great.
Any idea?
Aucun commentaire:
Enregistrer un commentaire