------------------------------ ### ### MINIMUM TECHNICAL REQUIREMENTS ### ###…
- User
------------------------------ ### ### MINIMUM TECHNICAL REQUIREMENTS ### ### ------------------------------ ### # Write a function that does the following! # 1) Display the name of a continent on the stage # 2) Display 2 countries on the continent # 3) Display a relevant stage background image def africa(): stage.set_background("jungle") africa = codesters.Text("Africa", -200, 225, "red") ethiopia = codesters.Text("Ethiopia", -200, 200, "white") stage.wait(3) ghana = codesters.Text("Ghana", -200, 175, "white") fact.set_text("Ghana means Warrior King.") stage.wait(3) ## Repeat the steps for all 7 continents (at least 7 functions!) def europe(): stage.set_background("flowers") europe = codesters.Text("Europe", 0, 225, "red") france = codesters.Text("France", 0, 200, "white") fact.set_color("white") fact.set_text_background("blue", "black", 1) fact.set_text("The Tour de France is a bike race\nthat is over 100 years old!") stage.wait(3) poland = codesters.Text("Poland", 0, 175, "white") fact.set_text("Marie Curie, a famous scientist who won 2 Nobel Prizes, was born in Poland.") stage.wait(3) def asia(): stage.set_background("park") asia = codesters.Text("Asia", 200, 225, "red") korea = codesters.Text("South Korea", 190, 200, "white") fact.move_down(100) fact.set_color("green") fact.set_text_background("tan", "brown", 1) fact.set_text("Taekwondo is the national sport of South Korea.") stage.wait(3) china = codesters.Text("China", 200, 175, "white") fact.set_text("The Great Wall of China is 13,171 miles long!") stage.wait(3) def oceania(): stage.set_background("underwater") oceania = codesters.Text("Oceania", -200, 125, "red") australia = codesters.Text("Australia", -200, 100, "white") fact.set_color("blue") fact.set_text_background("linen", "green", 1) fact.set_text("Australia is the only continent covered by a single country.") stage.wait(3) fiji = codesters.Text("Fiji", -200, 75, "white") fact.set_text("There are 333 tropical islands in Fiji!") stage.wait(3) def north_america(): stage.set_background("city") north_america = codesters.Text("North America", 0, 125, "red") usa = codesters.Text("USA", 0, 100, "white") fact.set_text_background("silver", "black", 1) fact.set_text("Alaska's the biggest state. It's 2.5 times the Texas!") stage.wait(3) mexico = codesters.Text("Mexico", 0, 75, "white") fact.set_text("Mexico is home to the world's smallest volcano!") stage.wait(3) def south_america(): stage.set_background("soccerfield") south_america = codesters.Text("South America", 180, 125, "red") peru = codesters.Text("Peru", 190, 100, "white") fact.set_text("Machu Picchu, a 15th century city, and one of the 7 wonders of the world, is in Peru!") stage.wait(3) ecuador = codesters.Text("Ecuador", 185, 75, "white") fact.set_text("Ecuador is on the equator!\nIt's in the Northern AND Southern hemispheres.") stage.wait(3) fact.hide() fact = codesters.Text("Ethiopia is the birthplace of coffee!", 0, 100, "gold") fact.set_text_background("grey", "black", 1) # Call all the functions africa() europe() asia() oceania() north_america() south_america() sprite = codesters.Sprite("earth", 100, -100)
CREATE: Display the names of 2 countries from each continent and a background picture for each continent. Bonus: Include a fun fact about each country!
- Assistant
- User
Function to perform the stage setup and display the continent, countries, and facts
def setup_continent(continent_name, country1, fact1, country2, fact2, bg_image, x, y): continent = codesters.Text(continent_name, x, y, "red") stage.wait(1)
country_name_1 = codesters.Text(country1, x, y - 25, "white") fact1_text = codesters.Text(fact1, x, y - 50, "gold") fact1_text.set_text_background("grey", "black", 1) stage.wait(2) country_name_2 = codesters.Text(country2, x, y - 75, "white") fact2_text = codesters.Text(fact2, x, y - 100, "gold") fact2_text.set_text_background("grey", "black", 1) stage.wait(2) # Hide the texts when moving to next continent to clean up the stage continent.hide() country_name_1.hide() fact1_text.hide() country_name_2.hide() fact2_text.hide() - Assistant
It looks like there's an issue with your script. Your loop is not complete and doesn't use the variables defined in the list. Furthermore, the function, which was correctly defined to handle the presentation, is not called within the loop.
- User
using stage.set_background("summer")
- Assistant
I see, you used
stage.set_background("summer")in your script, which likely sets the background to a summer-themed image. However, that line should not be inside the loop because each continent should have its specific background image set.Let me correct this for you. Just remove the line
stage.set_background("summer")from inside the loop and ensure that each call to thesetup_continentfunction uses thebg_imagevariable to set the correct background for each continent.Here's how your corrected loop should look:
# Loop through each continent's info and call the setup function for continent, country1, fact1, country2, fact2, bg_image, x, y in continents_info: stage.set_background(bg_image) # will set the background specific to each continent setup_continent(continent, country1, fact1, country2, fact2, bg_image, x, y) - User
put it together with the code
- Assistant