Repository: BondeYash/Python-Code Branch: main Commit: b08bb5ece2e6 Files: 6 Total size: 4.0 KB Directory structure: gitextract_nqs3c6v1/ ├── LICENSE ├── README.md ├── data.py ├── main.py ├── question_model.py └── quiz_brain.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2022 Yash Sanjay Bonde Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Python-Code This are Some of the Python Programs written by me # We will be uploading the Solidity Program written bY me We will Upload them soon We will start with the solidity as a Programming language ================================================ FILE: data.py ================================================ question_data = [ {"text": "A slug's blood is green.", "answer": "True"}, {"text": "The loudest animal is the African Elephant.", "answer": "False"}, {"text": "Approximately one quarter of human bones are in the feet.", "answer": "True"}, {"text": "The total surface area of a human lungs is the size of a football pitch.", "answer": "True"}, {"text": "In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.", "answer": "True"}, {"text": "In London, UK, if you happen to die in the House of Parliament, you are entitled to a state funeral.", "answer": "False"}, {"text": "It is illegal to pee in the Ocean in Portugal.", "answer": "True"}, {"text": "You can lead a cow down stairs but not up stairs.", "answer": "False"}, {"text": "Google was originally called 'Backrub'.", "answer": "True"}, {"text": "Buzz Aldrin's mother's maiden name was 'Moon'.", "answer": "True"}, {"text": "No piece of square dry paper can be folded in half more than 7 times.", "answer": "False"}, {"text": "A few ounces of chocolate can to kill a small dog.", "answer": "True"} ] ================================================ FILE: main.py ================================================ from question_model import Question from data import question_data from quiz_brain import Quizbrain question_bank = [] for question in question_data : qtext = question['text'] qanswer = question ['answer'] newquestion = Question (text=qtext , answer=qanswer) question_bank.append (newquestion) quiz = Quizbrain (question_bank) while quiz.still_has_question () : quiz.nextquestion () print ("Your Final score is : ") print (f"Your final score was : {quiz.score} / {quiz.question_number}") ================================================ FILE: question_model.py ================================================ class Question : def __init__(self ,text , answer) : self.text = text self.answer = answer ================================================ FILE: quiz_brain.py ================================================ from cv2 import correctMatches class Quizbrain : def __init__(self ,q_list) -> None: self.question_number = 0 self.question_list = q_list self.score = 0 def still_has_question (self) : return self.question_number < len (self.question_list) def nextquestion (self) : currquestion = self.question_list[self.question_number] self.question_number += 1 uinput = input (f"Q{self.question_number} : {currquestion.text} (True/False) ") self.checkanswer (uinput , currquestion.answer) def checkanswer (self , uinput , correctanswer): if uinput == correctanswer : self.score += 1 print ("You got it right ") else : print ("You got it right") print (f"The correct answer is {correctanswer}") print (f"Your current score is {self.score}/{self.question_number}") print ("\n")