Day 02 - Python Homework

Extended Assignments - Variables and String Formatting

Practice Python to improve your typing and coding skills. Use VS Code and create the files below. Run each program and check the output.

Remember to save your files with a .py extension and run them to see the output!

Assignment 01: Fruit Description with Variables

Extend the fruit description by adding more variables to describe the fruit in greater detail.

Think About:

1. Extra Details About the Fruit

  • Size (e.g., fruit_size = "medium")
  • Origin (e.g., origin_country = "India")
  • Season (e.g., best_season = "summer")
  • Taste (e.g., taste_profile = "sweet and tangy")
  • Smell (e.g., aroma = "fragrant")

2. Nutritional Information

  • Vitamins (e.g., vitamin_c_mg = 28.5)
  • Calories (e.g., calories_per_100g = 52)
  • Sugar content (e.g., sugar_g = 12.2)
  • Fiber content (e.g., fiber_g = 2.4)

3. Other Fun Facts

  • Is it rare? (e.g., is_rare = false)
  • Popularity (e.g., popularity_rating = 9.5)
  • Used in festivals? (e.g., used_in_festivals = true)

4. Your Own Ideas — Surprise Me!

  • days_since_harvest = 3
  • organic_certified = true
  • allergy_warning = "None"

Be creative and make your fruit description as detailed and interesting as possible!

Assignment 02: Printing Fruit Descriptions

Display your fruit variables in a structured way using formatted strings (f-strings).

Requirements:

  1. Header Section - Start with a title and include the fruit's name prominently
  2. Basic Details - Display color, size, origin, and season
  3. Nutritional Information - List key nutritional facts with units
  4. Fun Facts Section - Add creative details like rarity or popularity
  5. Formatting Tips - Use newlines (\n) to separate sections
Bonus Challenge: Add a "Did You Know?" section with a surprising fact.

Assignment 03: Student Bio & Story

Create variables and use f-strings to make a student biography and a short story.

Task 1: Student Bio

Task 2: Fairy Tale Short Story

Your Turn!

Now, try creating your own:

  1. A short student bio or a fairy tale using variables
  2. Format them into a message using f-strings

Bonus: Try adding more variables (like friends, favorite food, or a twist in the story).

If you need help

Post in the group with any of these problems:

Good luck and have fun coding!