Exercise: String formatting

Use f strings to complete these functions that return strings based on the input parameters.

Solar system

def solar_system(num_planets): """Returns a string like "There are NUM planets in the solar system" where NUM is provided as an argument. >>> solar_system(8) 'There are 8 planets in the solar system' >>> solar_system(9) 'There are 9 planets in the solar system' """ return "" # REPLACE THIS LINE

Location

def location(place, lat, lng): """Returns a string which starts with the provided PLACE, then has an @ sign, then the comma-separated LAT and LNG >>> location("Tilden Farm", 37.91, -122.29) 'Tilden Farm @ 37.91, -122.29' >>> location("Salton Sea", 33.309,-115.979) 'Salton Sea @ 33.309, -115.979' """ return "" # REPLACE THIS LINE

Fancy date

def fancy_date(month, day, year): """Returns a string of the format "On the DAYth day of MONTH in the year YEAR" where DAY, MONTH, and YEAR are provided. For simplicity, "th" is always the suffix, not "rd" or "nd". >>> fancy_date("July", 8, 2019) 'On the 8th day of July in the year 2019' >>> fancy_date("June", 24, 1984) 'On the 24th day of June in the year 1984' """ return "" # REPLACE THIS LINE

Dr. Evil

def dr_evil(amount): """Returns ' dollars', adding '(pinky)' at the end if the amount is 1 million or more. >>> dr_evil(10) '10 dollars' >>> dr_evil(1000000) '1000000 dollars (pinky)' >>> dr_evil(2000000) '2000000 dollars (pinky)' """ # YOUR CODE HERE
➡️ Next up: String operations