Online Questionere



https://opentdb.com/api.php?amount=10&category=11&difficulty=easy&type=boolean




question_data=[
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'Han Solo's co-pilot and best friend, "Chewbacca", is an Ewok.'
            ,
        'correct_answer': 'False',
        'incorrect_answers': ['True'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'The movie "The Nightmare before Christmas" was all done with physical objects.'
            ,
        'correct_answer': 'True',
        'incorrect_answers': ['False'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'Matt Damon played an astronaut stranded on an extraterrestrial planet in both of the movies Interstellar and The Martian.'
            ,
        'correct_answer': 'True',
        'incorrect_answers': ['False'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'The word "Inception" came from the 2010 blockbuster hit "Inception".'
            ,
        'correct_answer': 'False',
        'incorrect_answers': ['True'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'In the original script of "The Matrix", the machines used humans as additional computing power instead of batteries.'
            ,
        'correct_answer': 'True',
        'incorrect_answers': ['False'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'Ewan McGregor did not know the name of the second prequel film of Star Wars during and after filming.'
            ,
        'correct_answer': 'True',
        'incorrect_answers': ['False'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'In Alfred Hitchcock's film 'Psycho' it is said he used chocolate syrup to simulate the blood in the famous shower scene from '
            ,
        'correct_answer': 'True',
        'incorrect_answers': ['False'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'In the original Star Wars trilogy, David Prowse was the actor who physically portrayed Darth Vader.'
            ,
        'correct_answer': 'True',
        'incorrect_answers': ['False'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'In the original Star Wars trilogy, Alec Guinness provided the voice for Darth Vader.'
            ,
        'correct_answer': 'False',
        'incorrect_answers': ['True'],
        },
    {
        'category': 'Entertainment: Film',
        'type': 'boolean',
        'difficulty': 'easy',
        'question': 'Brandon Routh plays the titular character in the movie "John Wick".'
            ,
        'correct_answer': 'False',
        'incorrect_answers': ['True'],
        },
    ]



 import random

i=random.randint(0,len(question_data)-1)



class question_model:
  def __init__(self):
    pass


  def Question(self):
    i=random.randint(0,len(question_data)-1)
    self.q=question_data [i]["question"]
    self.a=question_data [i]["correct_answer"]
    






qsn_1=question_model()
qsn_2=question_model()
qsn_3=question_model()
qsn_4=question_model()
qsn_5=question_model()
qsn_6=question_model()
qsn_7=question_model()

qsn_1.Question()
qsn_2.Question()
qsn_3.Question()
qsn_4.Question()
qsn_5.Question()
qsn_6.Question()
qsn_7.Question()

Question_Bank=[
               qsn_1.q,
               qsn_2.q,
               qsn_3.q,
               qsn_4.q,
               qsn_5.q,
               qsn_6.q,
               qsn_7.q
]

Answer_Bank=[
               qsn_1.a,
               qsn_2.a,
               qsn_3.a,
               qsn_4.a,
               qsn_5.a,
               qsn_6.a,
               qsn_7.a
]

print(Question_Bank[0])
print(Question_Bank[1])
print(Question_Bank[2])
print(Question_Bank[3])
print(Question_Bank[4])
print(Question_Bank[5])
print(Question_Bank[6])

print(Answer_Bank[0])
print(Answer_Bank[1])
print(Answer_Bank[2])
print(Answer_Bank[3])
print(Answer_Bank[4])
print(Answer_Bank[5])
print(Answer_Bank[6])

Score = 0 
class questionere:
  def __init__(self,i):
    print("Q.{} {} (True/False) :".format(i+1,Question_Bank[i]))


for i in range(0,len(Question_Bank)):
  questionere_1=questionere(i)
  user_answer=input ()

  if (user_answer=='off'):
    break

  elif (user_answer==Answer_Bank[i]):
    print("Correct Answer")
    Score += 1
    print("Correct Answer was {}".format(Answer_Bank[i]))
    print("Now the Score is {}/{}".format(Score,i+1))

  else:
     print("Wrong Answer")
     Score -= 0.25
     print("Correct Answer was {}".format(Answer_Bank[i]))
     print("Now the Score is {}/{}".format(Score,i+1))


print("Your Final Score is {}".format(Score))

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings