Skip to content

Commit 19102f7

Browse files
authored
Add files via upload
1 parent 4355b85 commit 19102f7

File tree

14 files changed

+442
-442
lines changed

14 files changed

+442
-442
lines changed

Status/Day 1.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

22
# Question 1
3-
### Level 1
4-
-----------------
53

6-
**Question:**
4+
### **Question:**
75

8-
***Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
6+
> ***Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
97
between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line.***
108

119
--------------------------------------
12-
### Hints: Consider use range(#begin, #end) method
10+
### Hints:
11+
> ***Consider use range(#begin, #end) method.***
12+
1313
---------------------------------------
1414

1515
**Main author's Solution: Python 2**
16-
```
16+
```python
1717
l=[]
1818
for i in range(2000, 3201):
1919
if (i%7==0) and (i%5!=0):
@@ -24,7 +24,7 @@ print ','.join(l)
2424
----------------------------------------
2525

2626
**My Solution: Python 3**
27-
```
27+
```python
2828
for i in range(2000,3201):
2929
if i%7 == 0 and i%5!=0:
3030
print(i,end=',')
@@ -33,19 +33,19 @@ print("\b")
3333
-------------------------------
3434

3535
# Question 2
36-
### Level 1
37-
---------------
3836

39-
**Question:**
37+
### **Question:**
4038

41-
***Write a program which can compute the factorial of a given numbers.The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to the program: 8
39+
> ***Write a program which can compute the factorial of a given numbers.The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to the program: 8
4240
Then, the output should be:40320***
4341

4442
--------------------
45-
### Hints:In case of input data being supplied to the question, it should be assumed to be a console input.
43+
### Hints:
44+
>***In case of input data being supplied to the question, it should be assumed to be a console input.***
45+
4646
---------------
4747
**Main author's Solution: Python 2**
48-
```
48+
```python
4949
def fact(x):
5050
if x == 0:
5151
return 1
@@ -58,7 +58,7 @@ print fact(x)
5858
**My Solution: Python 3**
5959

6060
* **Using While Loop**
61-
```
61+
```python
6262
n = int(raw_input()) #input() function takes input as string type
6363
#int() converts it to integer type
6464
fact = 1
@@ -69,7 +69,7 @@ print fact(x)
6969
print(fact)
7070
```
7171
* **Using For Loop**
72-
```
72+
```python
7373
n = int(input()) #input() function takes input as string type
7474
#int() converts it to integer type
7575
fact = 1
@@ -80,21 +80,24 @@ print fact(x)
8080
-------------------
8181

8282
# Question 3
83-
## Level 1
84-
--------------------
85-
**Question:**
8683

87-
***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***
84+
### **Question:**
8885

89-
***Then, the output should be:
90-
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}***
86+
>***With a given integral number n, write a program to generate a dictionary that contains (i, i x 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***
9187

88+
>***Then, the output should be:***
89+
```
90+
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
91+
```
9292
------------------
93-
### Hints: In case of input data being supplied to the question, it should be assumed to be a console input.Consider use dict()
93+
94+
### Hints:
95+
>***In case of input data being supplied to the question, it should be assumed to be a console input.Consider use dict()***
96+
9497
-----------------
9598
9699
**Main author's Solution: Python 2**
97-
```
100+
```python
98101
n = int(raw_input())
99102
d = dict()
100103
for i in range(1,n+1):
@@ -103,15 +106,15 @@ print d
103106
```
104107

105108
**My Solution: Python 3:**
106-
```
109+
```python
107110
n = int(input())
108111
ans = {}
109112
for i in range (1,n+1):
110113
ans[i] = i * i
111114
print(ans)
112115
```
113116
**OR**
114-
```
117+
```python
115118
# This is done with dictionary comprehension method
116119
n = int(input())
117120
ans={i : i*i for i in range(1,n+1)}

0 commit comments

Comments
 (0)