2252_SY_Final_InLab

.py

School

Columbus State University *

*We aren’t endorsed by this school

Course

4247

Subject

Computer Science

Date

Apr 29, 2024

Type

py

Pages

4

Uploaded by DukeAntelope4207 on coursehero.com

#!/usr/bin/env python #this line is to ensures that the interpreter will use the first installed or default version of python on your system # FILE:2252_SY_Final_InLab.py # NAME: Question for a Champ # AUTHOR(s): Aliou SY # DATE: 08/05/2023 # PURPOSE: exp: This script is meant to engage user in a quizz about General knowledge #import random import random #questions, possible answers, and correct answers questions = [ "How many computer-generated effects were used in the movie Lord of the Rings - Return of the King?", "In the movie 'The Blues Brothers', what does Jake order at the diner?", "In The Simpsons, what football team has Homer always wanted to own?", "In the TV show Seinfeld, what did Elaine decide was 'her song'?", "Babe Ruth debuted in professional baseball at the age of 19 years old with which team?", "What is the name of the largest desert in the world?", "Which country is the only one to border both the Atlantic Ocean and the Indian Ocean?", "Which planet is the second smallest in the solar system?", "What is the name of the largest organ in the human body?", "Which musical genre originated in New Orleans in the early 20th century?", "Which planet is the only one in the solar system to be named after a Greek god, not a Roman one?", "Which country is the only one to have a flag that is not rectangular or square?" ] answers = [ ["540", "799", "1205", "*1488"], ["A medium pizza with pineapple and ham", "3 cheeseburgers with the works and a tall glass of milk", "*4 fried chickens and a Coke", "A small Greek salad with extra feta, a steak (well
done), 2 baked potatoes, and a coffee"], ["Washington Redskins", "*Dallas Cowboys", "Denver Broncos", "Cleveland Browns"], ["I am Woman", "Desperado", "Yesterday", "*Witchy Woman"], ["*Boston Red Sox", "New York Yankees", "St Louis Browns", "Cincinnati Red"], ["Sahara", "Gobi", "*Antarctica", "Kalahari"], ["Brazil", "Australia", "*South Africa", "Indonesia"], ["Mercury", "*Mars", "Venus", "Earth"], ["Heart", "Liver", "*Skin", "Brain"], ["Rock", "*Jazz", "Blues", "Reggae"], ["Mercury", "Venus", "Earth", "*Uranus"], ["Nepal", "*Switzerland", "Vatican City", "Japan"] ] # function to display a question and possible answers def display_question(question, answer): print(question) for i in range(len(answer)): #range of iteration if answer[i].startswith("*"): #finding answer using to the * in front print(str(i + 1) + ". " + answer[i][1:]) #printing question number 1-4 (len(answer)) and removing * with the index [1:] else: print(str(i + 1) + ". " + answer[i]) # function to check the player's answer and give feedback def check_answer(question, answer, player_answer): for i in range(len(answer)): #range of iteration if answer[i].startswith("*"): #finding answer using to the * in front correct_answer = i + 1 break if player_answer == correct_answer: print("Correct!") return 1 # Return 1 point for a correct answer else: print("Wrong! The correct answer is " + str(correct_answer) + ". " + answer[correct_answer-1][1:]) return 0 # Return 0 points for a wrong answer # function to play the game def play_game(): score = 0
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help