Created
August 15, 2021 16:14
-
-
Save onelharrison/9269e691fa5b5d534ebe2d0431b8bfb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def first_name(full_name: str) -> str: | |
"""Extracts and returns the first name from a full name""" | |
return full_name.split(" ")[0] | |
def square(n: int) -> int: | |
"""Returns the square of the given number""" | |
return n ** 2 | |
full_names = ["Ada Lovelace", "Katherine Johnson", "Marie Curie"] | |
first_names = list(map(first_name, full_names)) | |
print(first_names) # ["Ada", "Katherine", "Marie"] | |
squares = list(map(square, range(1, 10))) | |
print(squares) # [1, 4, 9, 16, 25, 36, 49, 64, 81] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment