Python Forum
Cannot Assign right Answers To Shuffled Questions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot Assign right Answers To Shuffled Questions
#4
You only need to shuffle the references to the questions and answers not the questions them selves. Observe :

from random import randint

questions = ['What is 2 plus 2?',
		'Why is there air?',
		'Who wrote the book of love?']

answers = ['a) 1\nb) 2\nc) 3\nd) 4',
		'a) To Breath\nb) To fly kits\nc) To fill volley balls\nd) All of the above',
		'a) Donald Trump\nb) BashBedlam\nc) The Monotones\nd) God']

correct_answers = ['d', 'd', 'c']

question_number = randint (0, 2)
print (questions [question_number])
print (answers [question_number])
print (f'The answer is {correct_answers [question_number]}.')
Boblows likes this post
Reply


Messages In This Thread
RE: Cannot Assign right Answers To Shuffled Questions - by BashBedlam - Jan-22-2021, 12:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  'answers 2' is not defined on line 27 0814uu 4 1,960 Sep-02-2023, 11:02 PM
Last Post: 0814uu
  Division calcuation with answers to 1decimal place. sik 3 3,023 Jul-15-2021, 08:15 AM
Last Post: DeaD_EyE
  Using answers from an input function Totalartist 3 3,211 Jul-19-2019, 02:02 PM
Last Post: snippsat
  Writing Answers From Questionnaire to a new .txt Document FizzyBreak579 4 4,708 Feb-16-2018, 07:26 AM
Last Post: buran
  Discord bot that asks questions and based on response answers or asks more questions absinthium 1 56,791 Nov-25-2017, 06:21 AM
Last Post: heiner55
  Need Answers 20nick20 6 6,901 Apr-29-2017, 04:06 PM
Last Post: Larz60+
  Code that generates MD5 hashes from IPv6 addresses giving differant answers? PyMD5 4 7,933 Oct-17-2016, 02:39 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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