From 43e0f9b666f62dbd9406d5d6fa1f29b2a1e495dc Mon Sep 17 00:00:00 2001 From: Ishant Sahu <105481974+ishant025@users.noreply.github.com> Date: Sun, 6 Oct 2024 15:47:17 +0530 Subject: [PATCH 1/4] Create KBC --- Game_Development/KBC | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Game_Development/KBC diff --git a/Game_Development/KBC b/Game_Development/KBC new file mode 100644 index 0000000000..1bde95b8b2 --- /dev/null +++ b/Game_Development/KBC @@ -0,0 +1,11 @@ +Modules Used: + +random: For selecting random questions and answers. +time: For adding slight delays between actions to make the game experience more dynamic. +Game Introduction: + +The game starts with a welcome message and prompts the player to enter their name. +Questions and Answers: + +A list of questions and corresponding answers is provided. +Each question also has a list of wrong answers (wronganswers) for generating multiple-choice options From b4a58e91bf63627a7c34c26d5fca11d59a6658d6 Mon Sep 17 00:00:00 2001 From: Ishant Sahu <105481974+ishant025@users.noreply.github.com> Date: Sun, 6 Oct 2024 15:48:00 +0530 Subject: [PATCH 2/4] Delete Game_Development/KBC --- Game_Development/KBC | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Game_Development/KBC diff --git a/Game_Development/KBC b/Game_Development/KBC deleted file mode 100644 index 1bde95b8b2..0000000000 --- a/Game_Development/KBC +++ /dev/null @@ -1,11 +0,0 @@ -Modules Used: - -random: For selecting random questions and answers. -time: For adding slight delays between actions to make the game experience more dynamic. -Game Introduction: - -The game starts with a welcome message and prompts the player to enter their name. -Questions and Answers: - -A list of questions and corresponding answers is provided. -Each question also has a list of wrong answers (wronganswers) for generating multiple-choice options From ce01069d3d9652eeb79b864991438e0c94dfd976 Mon Sep 17 00:00:00 2001 From: Ishant Date: Sun, 6 Oct 2024 16:40:21 +0530 Subject: [PATCH 3/4] Adding KBC game --- Game_Development/KBC/KBCquiz.py | 205 ++++++++++++++++++++++++++++++++ Game_Development/KBC/README.md | 87 ++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 Game_Development/KBC/KBCquiz.py create mode 100644 Game_Development/KBC/README.md diff --git a/Game_Development/KBC/KBCquiz.py b/Game_Development/KBC/KBCquiz.py new file mode 100644 index 0000000000..df3773beb3 --- /dev/null +++ b/Game_Development/KBC/KBCquiz.py @@ -0,0 +1,205 @@ +# Importing necessary modules +import random # For random selection of questions and options +import time # For adding delays to simulate a dynamic quiz experience + +# Print 120 asterisks for visual effect +for i in range(120): + print("*", end="") + time.sleep(0) + +# Print the welcome message +print() +print("\t\t\t Welcome to") +print("\t\t\t Kaun Banega Crorepati") + +# Print another line of asterisks +for i in range(120): + print("*", end="") + time.sleep(0) +print() + +# Ask the user to input their name +a = input("\t Enter Your Name - ") + +# Print another line of asterisks +for i in range(120): + print("*", end="") + time.sleep(0) +print() + +# Welcome message with the player's name +print("\n\tOK ", a, " Let's Start The Game") +time.sleep(1) + +# List of questions and their corresponding answers +questions = [ + "Who is The Prime Minister of India", + "In Which Country Area 51 is Located", + "Which one is the largest Continent in the world", + "What is the Latest Version of Windows Since 2019", + "Which One of these is not a Software Company", + "How Many MB Makes 1 GB", + "Facebook Was Firstly Developed By", + "Founder of Apple is", + "_________ is one of The Founder of Google", + "BIGG BOSS season 13 Starts in ____ & ends in _____", + "Apple's Laptop is Also Known as", + "First Apple Computer is Known as", + "Joystick is used For", + "____________ is used to Encrypt Drives in Computer" +] +answer = [ + "Narendra Modi", "United States", "Asia", "Windows 11", "Honda", "1024", + "Mark Zuckerberg", "Steve Jobs", "Larry Page", "2019 - 2020", "Macbook", + "Mactonish", "Playing Games", "Bitlocker" +] + +# List of wrong answers for each question (to generate multiple choices) +wronganswers = [ + ["Amit Shah", "Aditya Nath Yogi", "Azhar Ansari"], + ["India", "Africa", "Iraq"], + ["South Africa", "North America", "Europe"], + ["Windows 7", "Windows 8", "Windows 10"], + ["Oracle", "Microsoft", "Google"], + ["10024", "1004", "2024"], + ["Bill Gates", "Larry Page", "Azhar Ansari"], + ["Azhar Ansari", "Charles Babbage", "Sundar Pichai"], + ["Larry Hensberg", "Sunder Pichai", "Bill Gates"], + ["2020 - 2021", "Not Starts Now", "2018 - 2019"], + ["ThinBook", "Notebook", "ChromeBook"], + ["Apple v.1", "Apple Computer", "Appbook"], + ["Giving output command", "Shutting down Computer", "Log off Computer"], + ["KeyGuard", "Windows Secure", "No Software like this"] +] + +# Initialize variables for attempted questions, question count, and prize amount +attempquestion = [] +count = 1 +amount = 0 + +# Start the game loop +while True: + # Select a question that hasn't been asked yet + while True: + selectquestion = random.choice(questions) + if selectquestion in attempquestion: + pass # Skip if the question was already asked + else: + attempquestion.append(selectquestion) # Add the question to the attempted list + questionindex = questions.index(selectquestion) # Find the index of the selected question + correctanswer = answer[questionindex] # Get the correct answer for the question + break + + # Generate multiple choice options + optionslist = [] + inoptionlist = [] + optioncount = 1 + while optioncount < 4: # Pick three wrong answers + optionselection = random.choice(wronganswers[questionindex]) + if optionselection not in inoptionlist: + optionslist.append(optionselection) + inoptionlist.append(optionselection) + optioncount += 1 + optionslist.append(correctanswer) # Add the correct answer to the options list + + # Shuffle and display the options in random order + alreadydisplay = [] + optiontodisplay = [] + for _ in range(4): + while True: + a = random.choice(optionslist) + if a not in alreadydisplay: + alreadydisplay.append(a) + optiontodisplay.append(a) + break + + # Identify the correct option label (a, b, c, d) + right_answer = "" + if correctanswer == optiontodisplay[0]: + right_answer = "a" + elif correctanswer == optiontodisplay[1]: + right_answer = "b" + elif correctanswer == optiontodisplay[2]: + right_answer = "c" + elif correctanswer == optiontodisplay[3]: + right_answer = "d" + + # Display the question and options + print("--------------------------------------------------------------------------------------------") + print("\t\t\tAmount Win - ", amount) + print("--------------------------------------------------------------------------------------------") + time.sleep(1) + print("\n\t\tQuestion ", count, " on your Screen") + print("--------------------------------------------------------------------------------------------") + time.sleep(1) + print(" | Question - ", selectquestion) + print("--------------------------------------------------------------------------------------------") + time.sleep(1) + print("\t| A. ", optiontodisplay[0]) + print("\t-----------------------------------------------------------------------------") + time.sleep(1) + print("\t| B. ", optiontodisplay[1]) + print("\t-----------------------------------------------------------------------------") + time.sleep(1) + print("\t| C. ", optiontodisplay[2]) + print("\t-----------------------------------------------------------------------------") + time.sleep(1) + print("\t| D. ", optiontodisplay[3]) + print("\t-----------------------------------------------------------------------------") + + # Ask the player for their answer + useranswer = input("\t\tEnter Correct Option\t or \t press Q to quit.\n\t\t\t...").lower() + + # Check if the answer is correct + if useranswer == right_answer: + # Update the prize amount based on the number of correct answers + if count == 1: + amount = 10000 + elif count == 2: + amount = 20000 + elif count == 3: + amount = 50000 + elif count == 4: + amount = 100000 + elif count == 5: + amount = 400000 + elif count == 6: + amount = 800000 + elif count == 7: + amount = 1600000 + elif count == 8: + amount = 3200000 + elif count == 9: + amount = 6400000 + elif count == 10: + amount = 10000000 # Maximum prize for answering all questions correctly + print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") + print("*********************************************************************************") + print("\t\t\t !!!!!!!!!! Congratulations! !!!!!!!!!!") + print("\t\t\t||||||||||| You Won The Game |||||||||||") + print("*********************************************************************************") + print("\n\n\t\t You Won Rs. ", amount) + print() + break + + # Display message for correct answer and proceed to the next question + print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") + print("*********************************************************************************") + print("\t\t\t !!!!!!!!!! Congratulations! !!!!!!!!!!") + print("\t\t\t||||||||||||| Right Answer ||||||||||||||") + print("*********************************************************************************") + count += 1 + + # If the player chooses to quit + elif useranswer == "q": + print("\n\n\t\t You Won Rs. ", amount) + break + + # If the player provides a wrong answer + else: + print("*********************************************************************************") + print("\t\t\t\t\t\t\t\t Wrong Answer") + print("*********************************************************************************") + print("\n\n\t\t \t\t\t\t\t\t You Won Rs. ", amount) + print("*********************************************************************************") + break diff --git a/Game_Development/KBC/README.md b/Game_Development/KBC/README.md new file mode 100644 index 0000000000..254c431672 --- /dev/null +++ b/Game_Development/KBC/README.md @@ -0,0 +1,87 @@ + +# KBC Quiz Game 🎮 + +## 🎯 Objective + +This Python code creates a quiz game modeled after Kaun Banega Crorepati (KBC), where players answer multiple-choice questions to win increasing amounts of money. Here's an overview of the key parts of the code: + +--- + +**Modules Used**: + +* random: For selecting random questions and answers. +* time: For adding slight delays between actions to make the game experience more dynamic. + +**Game Introduction**: + +* The game starts with a welcome message and prompts the player to enter their name. + +**Questions and Answers**: + +* A list of questions and corresponding answers is provided. +* Each question also has a list of wrong answers (wronganswers) for generating multiple-choice options. + +**Question Loop**: + +* The game continuously presents questions to the player until they either answer incorrectly or choose to quit. +* For each question, a random question is selected from the list, along with random wrong answers and one correct answer. +* The answer options are then shuffled before being displayed to the player. + +**Winning Amount**: + +* The player earns progressively higher amounts with each correct answer, starting from ₹1,000 and going up to ₹1,500,000. +* If the player answers all 10 questions correctly, they win the game and the grand prize. + +**Game Termination:** + +* The game can end in three ways: +* The player answers incorrectly. +* The player quits by pressing "Q". +* The player answers all 10 questions correctly and wins the maximum amount. + +**Feedback:** + +* The game provides immediate feedback on whether the player's answer was correct or wrong, and displays their current winnings after each round. + +--- + +## 🚀 How to Play Kaun Banega Crorepati (KBC) Python Quiz Game + +1. **Start the Game**: Run the program to begin the quiz. +2. **Answering Questions**: +* The game will present you with a series of multiple-choice questions (MCQs). +* Each question will have four options (A, B, C, D). Only one option is the correct answer. +* To answer, simply type the letter of the correct option (e.g., a, b, c, or d) and press Enter. + +3. **Winning Amounts**: +* For each correct answer, you will win a certain amount of money. +* The amount increases as you answer more questions correctly +4. **Quitting the Game**: +* If you wish to quit at any point and take home your winnings, you can press the letter q when prompted for an answer. +* You will receive the total amount you’ve earned up until that point. +5. **Game Over - Wrong Answer**: +* If you provide a wrong answer, the game will end. +* Your winnings will be displayed, and you will not proceed to the next question. +6. **Winning the Game**: +* If you answer all 10 questions correctly, you will win the grand prize of ₹15,00,000! +* Congratulations will be displayed, and you’ll be crowned the winner of the game. + +--- + +## 🔧 How to Run + +1. Clone the repository and navigate to the project folder: + ```bash + git clone + cd + ``` + +2. Install dependencies (if any) and then run the program: + ```bash + python3 KBCquiz.py + ``` + +3. Enjoy playing the KBC game! + +--- + From d06bb0f9dd287ba772987b30e1d51bc0d92e1f8a Mon Sep 17 00:00:00 2001 From: Ishant Sahu <105481974+ishant025@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:46:29 +0530 Subject: [PATCH 4/4] Update README.md --- Game_Development/KBC/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Game_Development/KBC/README.md b/Game_Development/KBC/README.md index 254c431672..d55224e27f 100644 --- a/Game_Development/KBC/README.md +++ b/Game_Development/KBC/README.md @@ -9,8 +9,8 @@ This Python code creates a quiz game modeled after Kaun Banega Crorepati (KBC), **Modules Used**: -* random: For selecting random questions and answers. -* time: For adding slight delays between actions to make the game experience more dynamic. +* `random`: For selecting random questions and answers. +* `time`: For adding slight delays between actions to make the game experience more dynamic. **Game Introduction**: @@ -18,8 +18,8 @@ This Python code creates a quiz game modeled after Kaun Banega Crorepati (KBC), **Questions and Answers**: -* A list of questions and corresponding answers is provided. -* Each question also has a list of wrong answers (wronganswers) for generating multiple-choice options. +* A list of `questions` and corresponding `answers` is provided. +* Each question also has a list of wrong answers (`wronganswers`) for generating multiple-choice options. **Question Loop**: