Write a programElementary20 XPExercise 1/9
Lottery
Task
Write a function losuj() that returns a list of 10 different random whole numbers from 1 to 15 - no number may repeat.
Pick the numbers in a loop and check for repeats yourself; do not use random.sample. The main program under if __name__ == "__main__": prints the drawn numbers sorted.
Examples
Call
tahy = [losuj() for _ in range(200)] print(all(type(t) == list and len(t) == 10 for t in tahy)) print(all(len(set(t)) == 10 for t in tahy)) print(all(type(x) == int and 1 <= x <= 15 for t in tahy for x in t))
Expected output
True True True
Call
print(len({tuple(sorted(losuj())) for _ in range(50)}) > 1) vsetky = set() for _ in range(200): vsetky.update(losuj()) print(vsetky == set(range(1, 16)))Expected output
True True
Rules
Do not use
random.sample- pick the numbers in a loop.
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.