Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Write a function power(base, exponent=2). What are power(5), power(2, 10) and power(10, 3)?
A parameter with a default value is optional in the call.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. The function returns base ** exponent. The default exponent is 2.
power(5) uses the default: .power(2, 10) is .power(10, 3) is .Log in to join the discussion.
Loading…