Created
July 15, 2018 13:36
-
-
Save solen003/94fed33391513afdb603752069437b94 to your computer and use it in GitHub Desktop.
With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary. Suppose the following input is supplied to the program: 8 Then, the output should be: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
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
number = int(input("Type a number: ")) | |
numberDict = {} | |
for i in range(1, number+1): | |
numberDict[i] = i*i | |
print(numberDict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
number = int(input("Type a number: "))
numberDict = {3}
for i in range(1, number+1):
numberDict[i] = i*i
print(numberDict)