Skip to content

Commit dd4bd83

Browse files
authored
Merge pull request darkprinx#16 from apurvmishra99/master
Cleanup of all markdown files and addition of jupyter notebooks for all days
2 parents dfdf1fd + fca9aff commit dd4bd83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+8868
-1043
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5-
5+
copy/*
66
# C extensions
77
*.so
88

@@ -24,6 +24,7 @@ wheels/
2424
*.egg-info/
2525
.installed.cfg
2626
*.egg
27+
.idea
2728

2829
# PyInstaller
2930
# Usually these files are written by a python script from a template
@@ -99,3 +100,5 @@ ENV/
99100

100101
# mypy
101102
.mypy_cache/
103+
104+
clean_files.py

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Python-programming-exercises
2+
3+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/darkprinx/100-plus-Python-programming-exercises-extended/master?filepath=notebooks%2F)
24
---------------------
35
## Introduction
46

Status/Day 1.md

Lines changed: 84 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
21
# Question 1
32

43
### **Question:**
54

6-
> ***Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
7-
between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line.***
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).The numbers obtained should be printed in a comma-separated sequence on a single line._**
7+
8+
---
9+
10+
### Hints:
811

9-
--------------------------------------
10-
### Hints:
11-
> ***Consider use range(#begin, #end) method.***
12+
> **_Consider use range(#begin, #end) method._**
1213
13-
---------------------------------------
14+
---
1415

1516
**Main author's Solution: Python 2**
17+
1618
```python
1719
l=[]
1820
for i in range(2000, 3201):
@@ -21,30 +23,42 @@ for i in range(2000, 3201):
2123

2224
print ','.join(l)
2325
```
24-
----------------------------------------
26+
27+
---
2528

2629
**My Solution: Python 3**
30+
- **Using for loops**
31+
2732
```python
2833
for i in range(2000,3201):
2934
if i%7 == 0 and i%5!=0:
3035
print(i,end=',')
3136
print("\b")
3237
```
33-
-------------------------------
3438

39+
---
40+
- **Using generators and list comprehension**
41+
42+
```python
43+
print(*(i for i in range(2000, 3201) if i%7 == 0 and i%5 != 0), sep=",")
44+
```
3545
# Question 2
3646

3747
### **Question:**
3848

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
40-
Then, the output should be:40320***
49+
> **_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
50+
> Then, the output should be:40320_**
51+
52+
---
4153

42-
--------------------
4354
### Hints:
44-
>***In case of input data being supplied to the question, it should be assumed to be a console input.***
4555

46-
---------------
56+
> **_In case of input data being supplied to the question, it should be assumed to be a console input._**
57+
58+
---
59+
4760
**Main author's Solution: Python 2**
61+
4862
```python
4963
def fact(x):
5064
if x == 0:
@@ -54,58 +68,66 @@ def fact(x):
5468
x = int(raw_input())
5569
print fact(x)
5670
```
57-
------------
71+
72+
---
73+
5874
**My Solution: Python 3**
5975

60-
* **Using While Loop**
61-
```python
62-
n = int(raw_input()) #input() function takes input as string type
63-
#int() converts it to integer type
64-
fact = 1
65-
i = 1
66-
while i <= n:
67-
fact = fact * i;
68-
i = i + 1
69-
print(fact)
70-
```
71-
* **Using For Loop**
72-
```python
73-
n = int(input()) #input() function takes input as string type
74-
#int() converts it to integer type
75-
fact = 1
76-
for i in range(1,n+1):
77-
fact = fact * i
78-
print(fact)
79-
```
80-
* **Using Lambda Function**
81-
```python
82-
# Solution by: harshraj22
83-
84-
n = int(input())
85-
def shortFact(x): return 1 if x <= 1 else x*shortFact(x-1)
86-
print(shortFact(n))
87-
88-
```
89-
-------------------
76+
- **Using While Loop**
77+
```python
78+
n = int(input()) #input() function takes input as string type
79+
#int() converts it to integer type
80+
fact = 1
81+
i = 1
82+
while i <= n:
83+
fact = fact * i;
84+
i = i + 1
85+
print(fact)
86+
```
87+
- **Using For Loop**
88+
```python
89+
n = int(input()) #input() function takes input as string type
90+
#int() converts it to integer type
91+
fact = 1
92+
for i in range(1,n+1):
93+
fact = fact * i
94+
print(fact)
95+
```
96+
- **Using Lambda Function**
97+
98+
```python
99+
# Solution by: harshraj22
100+
101+
n = int(input())
102+
def shortFact(x): return 1 if x <= 1 else x*shortFact(x-1)
103+
print(shortFact(n))
104+
105+
```
106+
107+
---
90108

91109
# Question 3
92110

93111
### **Question:**
94112

95-
>***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***
113+
> **_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_**
114+
115+
> **_Then, the output should be:_**
96116
97-
>***Then, the output should be:***
98117
```
99118
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
100119
```
101-
------------------
102120

103-
### Hints:
104-
>***In case of input data being supplied to the question, it should be assumed to be a console input.Consider use dict()***
121+
---
105122

106-
-----------------
123+
### Hints:
124+
125+
> **_In case of input data being supplied to the question, it should be assumed to be a console input.Consider use dict()_**
126+
127+
---
107128

108129
**Main author's Solution: Python 2**
130+
109131
```python
110132
n = int(raw_input())
111133
d = dict()
@@ -115,27 +137,31 @@ print d
115137
```
116138

117139
**My Solution: Python 3:**
140+
141+
- **Using for loop**
142+
118143
```python
119144
n = int(input())
120145
ans = {}
121146
for i in range (1,n+1):
122147
ans[i] = i * i
123148
print(ans)
124149
```
125-
**OR**
150+
151+
- **Using dictionary comprehension**
152+
126153
```python
127-
# This is done with dictionary comprehension method
128154
n = int(input())
129155
ans={i : i*i for i in range(1,n+1)}
130156
print(ans)
131157
```
132-
----------------------------------
133158

134-
## Conclusion
135-
***These was the solved problems of day 1. The above problems are very easy for the basic syntex learners.I have shown some easy ways of coding in my solutions. Lets see how to face and attack new problems in the next day.***
159+
---
136160

137-
[***go to next day***](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%202.md "Next Day")
161+
## Conclusion
138162

163+
**_These was the solved problems of day 1. The above problems are very easy for the basic syntex learners.I have shown some easy ways of coding in my solutions. Lets see how to face and attack new problems in the next day._**
139164

165+
[**_go to next day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%202.md "Next Day")
140166

141-
[***Discussion***](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/issues/3)
167+
[**_Discussion_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/issues/3)

0 commit comments

Comments
 (0)