Python Forum
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Shuffle List
#6
(Oct-20-2016, 12:11 PM)Yoriz Wrote: Do you know how to use lists, loops and functions?
You  could make a list that has a (question,  answer) tuple, shuffle the list, loop the list passing each iteration to a function that deals with asking for input agianst the passed in question and checks the input against the passed in answer.

hmm, i barely know how to use lists, loops and functions really...

(Oct-20-2016, 12:08 PM)metulburr Wrote: use the random module
>>> import random >>> lister = [1,2,3] >>> random.choice(lister) 3 >>> random.choice(lister) 1 >>> random.choice(lister) 3 >>> random.choice(lister) 3 >>> random.choice(lister) 2 
and one method is then you can make your question and correct answers as a dict such as
questions = {     'answer 1':'Question 1',     'answer 1':'Question 2',     'answer 1':'Question 3', }
the second type looks easier but i need to use random.shuffle for this?
Reply


Messages In This Thread
Random Shuffle List - by simon - Oct-20-2016, 11:28 AM
RE: Random Shuffle List - by Yoriz - Oct-20-2016, 11:50 AM
RE: Random Shuffle List - by simon - Oct-20-2016, 12:00 PM
RE: Random Shuffle List - by metulburr - Oct-20-2016, 12:08 PM
RE: Random Shuffle List - by Yoriz - Oct-20-2016, 12:11 PM
RE: Random Shuffle List - by simon - Oct-20-2016, 12:35 PM
RE: Random Shuffle List - by metulburr - Oct-20-2016, 12:38 PM
RE: Random Shuffle List - by simon - Oct-20-2016, 12:39 PM
RE: Random Shuffle List - by simon - Oct-21-2016, 12:53 PM
RE: Random Shuffle List - by sparkz_alot - Oct-21-2016, 02:06 PM
RE: Random Shuffle List - by simon - Oct-24-2016, 04:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Random selection from list Mohsky 1 11,454 Mar-31-2020, 10:27 PM
Last Post: deanhystad
  printing list of random generated rectangles Zatoichi 8 7,439 Feb-18-2018, 06:34 PM
Last Post: buran
  bubble sort random list atux_null 7 8,013 Nov-03-2017, 07:28 PM
Last Post: sparkz_alot
  List with Random Numbers AnjyilLee 5 9,466 Oct-14-2017, 09:22 PM
Last Post: buran
  Using two functions to shuffle a deck of cards bwe587 7 9,286 Feb-15-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020