NOTE: You MAY change these functions or add more, but EVERY FUNCTION must RETURN a SINGLE VALUE
BONUS FOR FUNCTION CHAINS!!
Kermitβs leap across The Great Muppet Canyon is a multi-step challenge where each part of the jump is affected by different calculations, conditions, and randomness. To structure the program effectively, each step MUST be handled by its own function, and every function MUST return a single value rather than modifying global variables.
π Function Requirements
Each of the following actions MUST be implemented as a separate function:
get_jump_distance(leg_power, speed)Β
Calculates and returns Kermitβs initial jump distance.
apply_wind_resistance(distance)
Adjusts the jump distance based on wind effects and returns the new distance.
lily_pad_bounce(distance)Β
Checks if Kermit lands in a bounce zone and applies a bounce bonus if applicable.
Returns the updated distance.
check_landing_bonus(distance)Β
Determines if Kermit landed at an exact bonus spot and adds extra distance if applicable. Returns the updated distance.
attempt_aerial_trick(choice, distance)
If the user selects an aerial trick, randomly determines success/failure and applies a bonus/penalty. Returns the updated distance.
determine_final_result(distance)
Checks if Kermit made it across and returns a final success/failure message.
Kermit must leap across "The Great Muppet Canyon", but it's not just about jumping powerβhe must account for:
β Jump Speed πββοΈ
β Wind Resistance π¬
β Lily Pad Bounce Factor π¨
β Landing Precision π―
β BONUS: Aerial Tricks for Style Points! π€ΈββοΈ
π Step 1: User Input β Jump Power & Speed
The user enters:
Leg Power (1-10)
Speed Before Jumping (5-20 mph)
π’ Step 2: Basic Jump Distance Calculation
Formula for Jump Distance (ignoring physics for now)
Jump Distance=(Leg PowerΓ1.8)+(SpeedΓ0.5)
β Function returns the jump distance in feet.
β Print result: "Kermit jumps [X] feet! Ribbit-ribbit-hooray!"Β
π¬ Step 3: Apply Wind Resistance
Wind can either help or hinder Kermit!
π Wind Resistance Calculation:
Wind Factor=Random Value(β5 to +5)
β If positive, the wind helps Kermit.
β If negative, the wind pushes him back!
π’ New Jump Calculation:
Adjusted Jump=Jump Distance+Wind Factor
β Function returns new jump distance.
β Print result:
"The wind [helped/hurt] Kermit by [Y] feet! New distance: [Z] feet!"
π¨ Step 4: Lily Pad Bounce Factor!
If Kermit lands within a bounce zone (certain feet ranges), he rebounds!
π Bounce Rules:
If final jump lands between 15-25 feet
add random 3-7 feet bounce.
If final jump lands 30+ feet
add random 1-3 feet bounce.
Otherwise, no bounce.
β Function checks and returns new adjusted distance.
β Print:
"Kermit hit a springy lily pad! He bounces [Y] feet extra!"
π― Step 5: Landing Precision Bonus
If Kermit lands EXACTLY at 25, 30, or 40 feet:
π Bonus 5 feet for a perfect landing!
β Function checks for precise landing.
β Print:
"Perfect landing! Extra 5 feet added!"
π€ΈββοΈ BONUS: Aerial Tricks for Style Points!
Before jumping, the user chooses whether Kermit should try an aerial trick:
π Options:
1οΈβ£ No trick (safe)
2οΈβ£ Backflip (+3 feet if successful, -2 feet if failed)
3οΈβ£ Spin Kick (+5 feet if successful, -4 feet if failed)
β Success is random (50/50 chance).
β Function checks success, returns adjusted distance.
β Print result:
"Kermit attempted a backflip... [Success! +3 feet] OR [Oops! -2 feet]"
π FINAL RESULT: Total Jump Distance
All values are returned step by step through functions.
Final result prints:
"Kermitβs total jump distance is [X] feet! Did he make it across?"
π If distance < 25 feet, he falls into the river.
π If distance 25+ feet, he lands safely on the other side!
Gonzo is about to perform his most daring stunt everβa mid-air chicken rescue! However, his flight must be precisely calculated to avoid disaster! Students will write multiple single-return-value functions to calculate different aspects of the stunt.
π Function Requirements
Each step in Gonzoβs launch is handled by a separate function, ensuring a modular and structured approach.
β Step 1: Get User Input
get_cannon_power() β Returns user input for cannon power (must be between 10-100).
β Step 2: Calculate Initial Height
calculate_max_height(power) β Returns maximum height Gonzo reaches
β Step 3: Apply Air Resistance (If Needed)
apply_air_resistance(height, power)
Β If power > 80, applies a drag factor as shown
Otherwise, just return the height
β Step 4: Calculate Time in Air
calculate_air_time(height) β Returns Gonzoβs total flight time using the formula shown
Prints: "Gonzo stays airborne for [T] seconds!"
β Step 5: Check if Gonzo Catches the Chicken
determine_chicken_catch(height) β Determines if Gonzo catches the chicken
If height β₯ 50 feet: "Success! Gonzo grabs the chicken!"
Else: "Oh no! Gonzo misses and faceplants in popcorn!"
Returns "Success" or "Failure".
β Step 6: Wind Effect
apply_wind_factor(height) β Wind can help or hurt Gonzo!Β
Randomly adjust height by -5 to +5 feet and return the updated value.
β Step 7: Mid-Air Tricks for Extra Style!
attempt_mid_air_trick(choice, height) β The user selects whether Gonzo does a flip
"Backflip": +3 feet if successful, -2 feet if failed
"Spin Kick": +5 feet if successful, -4 feet if failed
Returns the adjusted height.
β Step 8: Final Landing Location
determine_landing(height, time)Β
If flight time > 5 sec, Gonzo overshoots the stage and lands in a popcorn stand.
Returns "Safe Landing" or "Popcorn Crash".