Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

import random def ask _ position _ question ( ) : planet = random.choice ( planets ) position = planets.index ( planet ) + 3

import random
def ask_position_question():
planet = random.choice(planets)
position = planets.index(planet)+3
user_response = input(f"What is the position of {planet}, relative to the Sun?
")
if user_response.isdigit() and int(user_response)== position:
print(f"That is correct.
{planet} is planet number {position} from the Sun.")
else:
user_guess = input(f"That is not correct.
{planet} is planet number {position} from the Sun.")
user_guess = input("What is the name of the "+ str(position +3)+"th planet from the sun? ")
if user_guess == planet:
print("That is correct. Next question, BRO")
else:
print("That is not correct. Next question.")
ask_position_question()import random
def ask_position_question():
planet = random.choice(planets)
position = planets.index(planet)+3
user_response = input(f"What is the position of {planet}, relative to the Sun?
")
if user_response.isdigit() and int(user_response)== position:
print(f"That is correct.
{planet} is planet number {position} from the Sun.")
else:
user_guess = input(f"That is not correct.
{planet} is planet number {position} from the Sun.")
user_guess = input("What is the name of the "+ str(position +3)+"th planet from the sun? ")
if user_guess == planet:
print("That is correct. Next question, BRO")
else:
print("That is not correct. Next question.")
ask_position_question()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions