ComeçarComece de graça

Write a pure function

It's time to write your first pure function! You've been working with some data that contains price information for all of the items in your company's inventory. What you didn't realize when you started, however, was that all of the price information is in cents when you expected it to be in dollars. You are going to need to write a function to convert all of the prices from cents to dollars by dividing the values by 100. Make sure you don't create any side effects or rely on any values outside of the function!

Este exercício faz parte do curso

Programming Paradigm Concepts

Ver curso

Instruções do exercício

  • Complete the code below to write a pure function that takes a list (input_list) as input, divides each item in the list by 100, and then returns the new list.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

def square_list(input_list):
    new_list = []
    # Loop through each item in the input list
    for item in ____:
        # Divide each item by 100
        new_item = ____ / 100
        # Append the new item to the new list
        new_list.append(____)
    # Return the new list
    return ____
Editar e executar o código