'F' → Fullscreen
Create a new Python program named 1-13-while-loops.
import random
print("--- Demo 1 - 99 Bottles Song ---")soda = input("Enter your favorite soda:")bottles = 99
while bottles > 0: print(f"{bottles} bottles of {soda} on the wall,") print(f"{bottles} bottles of {soda}!") print("You take one down, pass it around,") bottles = bottles - 1 print(f"{bottles} bottles of {soda} on the wall!")
input("Press enter to continue...")import random
print("--- Demo 1 - 99 Bottles Song ---")soda = input("Enter your favorite soda:")bottles = 99
while bottles > 0: print(f"{bottles} bottles of {soda} on the wall,") print(f"{bottles} bottles of {soda}!") print("You take one down, pass it around,") bottles = bottles - 1 print(f"{bottles} bottles of {soda} on the wall!")
input("Press enter to continue...")
print("--- Demo 2 - Turn-Based Battle ---")
player_health = 10enemy_health = 6fighting = True
while fighting: print("Health:", player_health) print("Goblin:", enemy_health) print("-Menu-") print("1) Attack") print("2) Heal") choice = input("->").lower()
if choice == "1" or choice == "attack": print("Player attacks!") player_attack = random.randint(0, 5)
if player_attack > 0: print(f"You did {player_attack} damage.") enemy_health = enemy_health - player_attack else: print("Missed!") elif choice == "2" or choice == "heal": potion = random.randint(1, 3) print(f"Healed {potion} points.") player_health = player_health + potion else: print("Invalid option. You lose your turn!")
if enemy_health > 0: print("Goblin attacks!") enemy_attack = random.randint(0, 3)
if enemy_attack > 0: print(f"Goblin did {enemy_attack} damage.") player_health = player_health - enemy_attack else: print("Missed!") else: print("Goblin defeated!") fighting = False
if player_health <= 0: print("You were defeated!") fighting = FalseVerify your program works correctly.
--- Demo 1 - 99 Bottles Song ---Enter your favorite soda: Code Zero [Enter]99 bottles of Code Zero on the wall,99 bottles of Code Zero!You take one down, pass it around,98 bottles of Code Zero on the wall!...Press enter to continue...--- Demo 2 - Turn-Based Battle ---Health: 10Goblin: 6-Menu-1) Attack2) Heal-> 1Player attacks!You did 3 damage.Goblin attacks!Missed!Health: 10Goblin: 3-Menu-1) Attack2) Heal-> 1Player attacks!You did 4 damage.Goblin defeated!Answer the following questions before submitting your work.
while fighting: loop running?enemy_health and player_health at the end of every pass, instead of just once at the start?Submit the required files to the appropriate dropbox.