# Math πrate and Sam are extremely happy to have completed their quests.
# Now they are aiming for brownie points.
# Are you ready to help them?
''' Task 1: Field Trip '''
print("***** Task 1: *****")
print()
# A teacher is planning a school trip to a theme park.
# Write a program to workout the cost of the trip by following the below conditions:
# - Only 30 students are allowed for the trip
# - The cost per student is INR 1200.
# - For every 10th student you don't take the cost into consideration
students = 30
cost = 0
for i in range(1, students+1):
if i % 10 == 0:
continue
else:
cost += 1200
print(f"The total cost for the school trip is {cost}")
''' Task 2: DVD Rental '''
print("***** Task 2: *****")
print()
# Shreya has just joined a DVD rental club. She pays a monthly membership fee of $4.95, and each DVD rental is $1.95.
# Shreya is given a budget every month by her parents to rent DVDs. The rental shop has a rule that one cannot rent more than 20 DVDs in a month.
# Write a program that displays the number of DVD's Shreya gets to rent for the budget given to her each month.
budget = float(input("Enter your monthly budget: "))
dvds_rented = 0
current_cost = 4.95
for count in range(1, 22):
if count > 20:
break
else:
if current_cost + 1.95 > budget:
break
else:
current_cost = current_cost + 1.95
dvds_rented = dvds_rented + 1
if budget < 4.95:
dvds_rented = 0
print(f"Number of DVDs Shreya can rent: {dvds_rented}")
''' Task 3: Unscramble the Word '''
print("***** Task 3: *****")
print()
# Have you played the "Unscramble the Word" game?
# In this game, a word is jumbled and one has to find the right word.
# Write a program that gives scrambled words and asks the user to type in the right word. The user gets only two chances to guess .
choice = ["tpyohn","kymone","tstaacopreh"]
scrambled_word = input(f"Choose which scrambled word youwould like to solve: {choice}")
if scrambled_word == choice[(0)]:
correct_word = "python"
print(f"Scrambled word: {scrambled_word}")
for attempt in range(1, 4):
if attempt > 2:
print(f"Game over! The correct word was: {correct_word}")
break
else:
guess = input(f"Attempt {attempt} - Enter your guess: ")
if guess.lower() == correct_word:
print(f"Correct! You solved it in {attempt} attempt(s).")
break
else:
if attempt == 1:
print(f"Wrong guess. Try again!")
else:
continue
if scrambled_word == choice[(1)]:
correct_word = "monkey"
print(f"Scrambled word: {scrambled_word}")
for attempt in range(1, 4):
if attempt > 2:
print(f"Game over! The correct word was: {correct_word}")
break
else:
guess = input(f"Attempt {attempt} - Enter your guess: ")
if guess.lower() == correct_word:
print(f"Correct! You solved it in {attempt} attempt(s).")
break
else:
if attempt == 1:
print(f"Wrong guess. Try again!")
else:
continue
if scrambled_word == choice[(2)]:
correct_word = "catastrophe"
print(f"Scrambled word: {scrambled_word}")
for attempt in range(1, 4):
if attempt > 2:
print(f"Game over! The correct word was: {correct_word}")
break
else:
guess = input(f"Attempt {attempt} - Enter your guess: ")
if guess.lower() == correct_word:
print(f"Correct! You solved it in {attempt} attempt(s).")
break
else:
if attempt == 1:
print(f"Wrong guess. Try again!")
else:
continue
else:
print("Please try again and choose one fo the scrambled words given.")
'''Kudos!! You have aced the use of the break and continue keywords in the for loop. Way to go!!'''
To embed this project on your website, copy the following code and paste it into your website's HTML: