Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6546129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:40:13+00:00 2026-05-25T11:40:13+00:00

In the code below (which shows all my neophyteness in Python), I took the

  • 0

In the code below (which shows all my neophyteness in Python), I took the books of the KJV Bible and put them in logical order via a list and dictionary. I then used a random method to display 5 random books to a user along with the position of the each book in a random list for the user to match (something for me to better learn the books of the Bible). My difficulty is figuring out how to go about saving the results and tallying up the number correct/wrong. I also would like to give the user an option to choose the number of questions like 10, 15, 20, or 30 …. Can someone give me direction on this? Thanks!

import random
import os

if __name__=='__main__':

    books=['Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy', 'Joshua',
       'Judges', 'Ruth', 'I Samuel', 'II Samuel', 'I Kings', 'II Kings',
       'I Chronicles', 'II Chronicles', 'Ezra', 'Nehemiah', 'Esther', 'Job', 'Psalms',
       'Proverbs', 'Ecclesiastes', 'Song of Solomon', 'Isaiah', 'Jeremiah',
       'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel', 'Amos', 'Obadiah',
       'Jonah', 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah', 'Haggai', 'Zechariah',
       'Malachi', 'Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans', 'I Corinthians',
       'II Corinthians', 'Galatians', 'Ephesians', 'Philippians',
       'Colossians', 'I Thessalonians', 'II Thessalonians', 'I Timothy', 'II Timothy',
       'Titus', 'Philemon', 'Hebrews', 'James', 'I Peter', 'II Peter', 'I John',
       'II John', 'III John', 'Jude', 'Revelation']

Title = "{0:^78}".format("Welcome to the Bible book quiz!\n\n")



seleCtion = raw_input(" The Bible has a number of " + str(len(books)) + " books.\n Select Next to see them below:\n" + "{0:^78}".format("[1]Next    [2]Exit\n") )

if seleCtion == '1':

 #This section displays the books of the Bible and their indexes.
    count = 1
    indexMap = {}

    for i, bname in enumerate(books):
        print '\n{0:3d}. {1}'.format(count, bname)
        indexMap[count] = i
        count +=1


elif seleCtion == '2':
    print Title
    print "\n Let's start the quiz:\n\n\n"


else:
    print 'You must select 1 or 2'



mydict_book = {'Genesis':1, 'Exodus':2, 'Leviticus':3, 'Numbers':4, 'Deuteronomy':5, 'Joshua':6,
       'Judges':7, 'Ruth':8, 'I Samuel':9, 'II Samuel':10, 'I Kings':11, 'II Kings':12,
       'I Chronicles':13, 'II Chronicles':14, 'Ezra':15, 'Nehemiah':16, 'Esther':17, 'Job':18, 'Psalms':19,
       'Proverbs':20, 'Ecclesiastes':21, 'Song of Solomon':22, 'Isaiah':23, 'Jeremiah':24,
       'Lamentations':25, 'Ezekiel':26, 'Daniel':27, 'Hosea':28, 'Joel':29, 'Amos':30, 'Obadiah':31,
       'Jonah':32, 'Micah':33, 'Nahum':34, 'Habakkuk':35, 'Zephaniah':36, 'Haggai':37, 'Zechariah':38,
       'Malachi':39, 'Matthew':40, 'Mark':41, 'Luke':42, 'John':43, 'Acts':44, 'Romans':45, 'I Corinthians':46,
       'II Corinthians':47, 'Galatians':48, 'Ephesians':49, 'Philippians':50,
       'Colossians':51, 'I Thessalonians':52, 'II Thessalonians':53, 'I Timothy':54, 'II Timothy':55,
       'Titus':56, 'Philemon':57, 'Hebrews':58, 'James':59, 'I Peter':60, 'II Peter':61, 'I John':62,
       'II John':63, 'III John':64, 'Jude':65, 'Revelation':66}    



#new_dict = dict.fromkeys(books, counter)
#print new_dict




while 1:
    try:
        #This section starts the random book selection index match
        user_sel = []


        print '\n\n\n Here are the first 5 books in the quiz: \n'    
        sampler =random.sample(books, 5)
        first = str(sampler[0])
        second = str(sampler[1])
        third = str(sampler[2])
        fourth = str(sampler[3])
        fifth = str(sampler[4])
        user_sel = mydict_book[first], mydict_book[second], mydict_book[third], mydict_book[fourth], mydict_book[fifth]
        num_sampler = random.sample(user_sel, 5)

        print sampler
        print '\nMatch the correct numeric position below:'
        print '\n', num_sampler

        samp1 = int(raw_input('\nWhich number is ' + sampler[0] +': '))
        samp2 = int(raw_input('Which number is ' + sampler[1] +': '))
        samp3 = int(raw_input('Which number is ' + sampler[2] +': '))
        samp4 = int(raw_input('Which number is ' + sampler[3] +': '))
        samp5 = int(raw_input('Which number is ' + sampler[4] +': '))


        # taking the the users answer and finding the resultant book
        # need to put an if statement condition for !< 1 and ! < 66
        answer1=books[samp1-1]
        answer2=books[samp2-1]
        answer3=books[samp3-1]
        answer4=books[samp4-1]
        answer5=books[samp5-1]

        # taking the book and finding the numeric value associated with it


        right1 = mydict_book[answer1]
        right2 = mydict_book[answer2]
        right3 = mydict_book[answer3]
        right4 = mydict_book[answer4]
        right5 = mydict_book[answer5]



        #display what my answers yield
        print '\nYour Answers yield:\n'
        print "1. " + str(answer1) 
        print "2. " + str(answer2) 
        print "3. " + str(answer3)
        print "4. " + str(answer4)
        print "5. " + str(answer5)

        #takes the random books converts them to strings
        first = str(sampler[0])
        second = str(sampler[1])
        third = str(sampler[2])
        fourth = str(sampler[3])
        fifth = str(sampler[4])

        # print the numeric value and string value of the correct answers.         
        print "\nThe Correct Answers are:\n"
        print sampler[0] + " - " , mydict_book[first], tstmnt
        print sampler[1] + " - " , mydict_book[second], tstmnt
        print sampler[2] + " - " , mydict_book[third], tstmnt
        print sampler[3] + " - " , mydict_book[fourth], tstmnt
        print sampler[4] + " - " , mydict_book[fifth], tstmnt


        continue


    except ValueError:
        break
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:40:13+00:00Added an answer on May 25, 2026 at 11:40 am
    import random
    import os
    
    if __name__=='__main__':
    
        books = ['Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy',
                 'Joshua', 'Judges', 'Ruth', 'I Samuel', 'II Samuel', 'I Kings',
                 'II Kings', 'I Chronicles', 'II Chronicles', 'Ezra', 'Nehemiah',
                 'Esther', 'Job', 'Psalms', 'Proverbs', 'Ecclesiastes',
                 'Song of Solomon', 'Isaiah', 'Jeremiah', 'Lamentations',
                 'Ezekiel', 'Daniel', 'Hosea', 'Joel', 'Amos', 'Obadiah', 'Jonah',
                 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah', 'Haggai', 'Zechariah',
                 'Malachi', 'Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans',
                 'I Corinthians', 'II Corinthians', 'Galatians', 'Ephesians',
                 'Philippians', 'Colossians', 'I Thessalonians',
                 'II Thessalonians', 'I Timothy', 'II Timothy', 'Titus',
                 'Philemon', 'Hebrews', 'James', 'I Peter', 'II Peter', 'I John',
                 'II John', 'III John', 'Jude', 'Revelation']
    
        mydict_book = dict((bname,i) for i,bname in enumerate(books,start=1))
    
    
    while True:
        seleCtion = raw_input(" The Bible has a number of %s books.\n" % len(books) \
                              + "Select Next to see them below:\n" \
                              + "{0:^78}".format("[1]Print All books   [2]Start Quiz\n"))
    
        if seleCtion == '1':
            print '\n'.join('{0:3d}. {1}'.format(i, bname) for i,bname in mydict_book.iteritems())
            break
    
        elif seleCtion == '2':
            print "{0:^78}\nLet's start the quiz:\n\n".format("Welcome to the Bible book quiz!\n\n")
            break
    
        else:
            print 'You must select 1 or 2'
    
    
    while 1:
        try:
            num_ques = int(raw_input('\nEnter the number of questions you wanna be asked: '))
            sampler  = random.sample(books, num_ques)
            if not sampler:  exit(0)
    
            num_sampler = map(lambda bname: mydict_book[bname] , sampler)
            print 'num_sampler==',num_sampler
    
            print ('\n\n\nHere are the first %s books in the quiz: \n%s'
                   '\nMatch the correct numeric positions below :\n%s') \
                   % (num_ques,  str(sampler)[1:-1],  str(random.sample(num_sampler,num_ques))[1:-1])
    
            samp = [ int(raw_input('\nWhich number is %s : ' % books[i-1])) for i in num_sampler ]
    
            your = zip(samp,sampler)
            your.sort()
            print '\nYour Answers yield:\n' + '\n'.join('%2s. %s' % (n,bk) for n,bk in your)
    
            correct = zip(num_sampler,sampler)
            correct.sort()
            print "\nThe Correct Answers are:\n" + '\n'.join('%2s - %s' % (n,bk) for n,bk in correct) 
    
            continue
    
    
        except ValueError:
            break
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below shows a rectangle class using double points, which are also stored
So far i have got the code below which works lovely when trying an
Hello friends i am running code given below which contains the setLogTimeEntery function and
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
Can anyone help me to rewrite the below code which use a fade effect
The code below is resulting in an error on a site in which there
The code below works unless p.School.SchoolName turns out to be null, in which case
I have the code below, which works fine it can be viewed for an
In the sample code below I am dividing by zero which when I step
I have the code below, which sends the value of the textarea and either

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.