Skip to content

Commit 3cd2f83

Browse files
committed
2 solution to problem 3
1 parent 2723ab9 commit 3cd2f83

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

q1.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
#Question 1
2-
#Level 1
3-
#
4-
#Question:
5-
#Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
6-
#between 2000 and 3200 (both included).
7-
#The numbers obtained should be printed in a comma-separated sequence on a single line.
8-
#
9-
#Hints:
10-
#Consider use range(#begin, #end) method
11-
121
def printnumbers():
132
numbers = []
143
k=1
@@ -25,5 +14,20 @@ def fact(n):
2514
fa = fa * d
2615
return fa;
2716

28-
n = int(input('Number --> '))
29-
print(fact(n))
17+
#n = int(input('Number --> '))
18+
#print(fact(n))
19+
20+
#Problem 3, asks to print a dictionary where values are square of the key. n is input.
21+
22+
def sqdic(n):
23+
return {x: x*x for x in range(1,n+1)}
24+
25+
def sqdic2(n):
26+
d = {}
27+
for x in range(1,n+1):
28+
d[x] = x*x;
29+
return d
30+
31+
n = int(input("Number->"))
32+
print(sqdic2(n))
33+

0 commit comments

Comments
 (0)