6.1. Exercises
Function Questions
def add_stars(name):
name = "**" + name + "**"
returnCoding questions
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.
Making a Function from Existing Code
Let’s practice converting existing code into a function so that it complies with the DRY principle.
Tasks:
- Using the code provided, transform it into a function named
uppercase_count - The function should take in one argument and return the number of uppercases in the string
- Test it on the string
I hope you've Been Learning ALOT!
Making a Function
Let’s practice making a function that returns the BMI (Body Mass Index) given a person’s weight and height.
Tasks:
- Define a function and give it the name
BMI_calculator. - It should take 2 arguments which can be called
height, andweight. - BMI can be calculated as:

- Make sure the function returns the calculated BMI.
- Once you have created your function, use it to calculate the BMI of a person with a height of 62 inches and a weight of 105 lbs.
- Save this in an object name
bmi_calc.