Last active
January 7, 2016 05:56
-
-
Save codeboy101/575aa554d559777cd36d to your computer and use it in GitHub Desktop.
This file contains 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
##okay so we want to make a list of square of numbers 1 to 5 : | |
## so we can do it like this : | |
square_list = [] | |
for i in range(1,6) : | |
square_list.append(i**2) | |
print(square_list) | |
## or by using list comprehension : | |
square_list = [i**2 for i in range(1,6)] | |
# a dictionary showing number:square of number | |
square_dict ={n:n**2 for n in range(1,6)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment