Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 52b9ec4

Browse files
more solved programs
1 parent 65cbc2e commit 52b9ec4

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

‎Day 2/remove-duplicates.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
s = input("Enter a string: ")
2+
3+
string_set = set()
4+
s2 = ''
5+
6+
for c in s:
7+
if c not in string_set:
8+
string_set.add(c)
9+
s2 += c
10+
11+
print(s2)

‎Day 2/sum-of-primes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def is_prime(x):
2222

2323

2424
# Do not read if you're a beginner
25+
# And if you're not, you already know not to do this :)
2526
print(reduce(lambda a, b: a + b, filter(is_prime, list(range(n1, n2+1)))))

‎Day 2/sum-of-series.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
n = int(input('Enter the number of terms: '))
2+
s = 0
3+
4+
for i in range(1, n + 1):
5+
s += 1 / i
6+
7+
print(s)
8+
print('%.3f' %s)
9+
print('{:.3f}'.format(s))
10+
print(f'{s:.3f}')
11+
12+
print(sum(1/i for i in range(1, int(input('Enter the number of terms: '))+1)))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /