Question: Python Language a) In this exercise, you will combine slicing with for statements. Given the following list: sports = ['Football', 'Volleyball', 'Basketball', 'Baseball', 'Handball', 'Softball']

Python Language

a) In this exercise, you will combine slicing with for statements. Given the following list:

sports = ['Football', 'Volleyball', 'Basketball', 'Baseball', 'Handball', 'Softball']

Write some code that extracts, from each word, all the letters except 'ball' at the end of each one. Save the output in a list named mod_sports, and print it.

b) Using for and if statements.

Populate a list called numbers that will go from 0 up to 100 where, if the number is divisible by 3 and 5, you replace it by the word "FizzBuzz"; if the number is divisible by 3, you replace it by "Fizz"; and if the number is divisible by 5, you replace it by "Buzz". All the remaining numbers should remain as numbers.

Note: You have to use for statements and if statements together.

Tips:

  • Look into the % operator.
  • To check if something is equal to 0, remember you need to use the == comparison operator.

Note: After you finish, you can use the print statement to check your numbers list.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!