-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython 2.py
More file actions
49 lines (27 loc) · 951 Bytes
/
Copy pathpython 2.py
File metadata and controls
49 lines (27 loc) · 951 Bytes
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
39
40
41
42
43
44
45
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
3. 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 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}
# In[7]:
n=int(input('please enter any value:'))
c={i:i*i for i in range(1,n+1)}
print(c)
# In[ ]:
4.Write a program which accepts a sequence of comma-separated numbers from console
and generate a list and a tuple which contains every number.
Suppose the input is supplied to the program: 34, 67, 55, 33, 12, 98
Then, the output should be:
['34', '67', '55', '33', '12', '98']
('34', '67', '55', '33', '12', '98')
# In[6]:
a=input('enter').split(',')
b=[]
for i in a:
b.append(i)
print(b)
c=tuple(b)
print(c)
# In[ ]: