Sunday, September 1, 2019

IslandT: Multiply according to the number of times

In this example, a root number and the number which indicates how many numbers of times that root number should get multiplied have been passed into a function which will then return a list of multiplied numbers of that original number. For example, if we pass in 3 and 5 to this method multiples(3, 5), we will receive a list of multiplied numbers: [5, 10, 15].

def multiples(m, n):
    arr = []
    for number in range(1, m+1):
        arr.append(n * number)
    return arr

As you can see, the m parameter has been used in the range method to create the multiplied numbers list.

Your Homework :

Create a method which will only return the multiplied numbers that are not larger than the power of m for the given n number. Provide your answer in the tweet below.

If you are serious about learning Python, then homework is the best method to improve your Python skill!



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...