-
Notifications
You must be signed in to change notification settings - Fork 0
/
W6_PA2.py
38 lines (21 loc) · 977 Bytes
/
W6_PA2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Given a positive integer number n, you have to write a program that generates a dictionary d which contains
# (i, i*i*i) such that i is the key and i*i*i is its value, where i is from 1 to n (both included).
# Then you have to just print this dictionary d.
# Example:
# Input: 4
# will give output as
# {1: 1, 2: 8, 3: 27, 4: 64}
# Input Format:
# Take the number n in a single line.
# Output Format:
# Print the dictionary d in a single line.
# Example:
# Input:
# 8
# Output:
# {1: 1, 2: 8, 3: 27, 4: 64, 5: 125, 6: 216, 7: 343, 8: 512}
# Explanation:
# Here n is 8, we will start from i=1, hence the first element of the dictionary is (1: 1),
# as i becomes 2, the second element of the dictionary becomes (2: 8) and so on.
# Hence the output will be {1: 1, 2: 8, 3: 27, 4: 64, 5: 125, 6: 216, 7: 343, 8: 512}.
# -----------------------------------------------------------------------------------------------------