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 7bac056

Browse files
added more codes
1 parent d8a1c72 commit 7bac056

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

‎Day 4/copied-file.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is a file
2+
copy me
3+
:)

‎Day 4/count-vowels.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
vowels = set('aeiouAEIOU')
2+
s = input('Enter a string: ')
3+
4+
sum_ = 0
5+
for vowel in vowels:
6+
sum_ += s.count(vowel)
7+
8+
print(sum_)
9+
10+
sum_ = 0
11+
for c in s:
12+
if c in vowels:
13+
sum_ += 1
14+
15+
print(sum_)

‎Day 4/file-copy.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
with open('file.txt', 'r') as f:
2+
with open('copied-file.txt', 'w') as fc:
3+
fc.write(f.read())
4+

‎Day 4/file.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is a file
2+
copy me
3+
:)

‎Day 4/pascal-triangle2.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''
2+
1 0
3+
1 1 0
4+
1 2 1 0
5+
1 3 3 1 0
6+
1 4 6 4 1 0
7+
'''
8+
n = int(input('Enter the number of lines: '))
9+
10+
p = [1]
11+
12+
for i in range(n):
13+
print(' ' * (n-i-1) + ' '.join(map(str, p)))
14+
p.append(0)
15+
for j in range(len(p) - 1, 0, -1):
16+
p[j] = p[j] + p[j - 1]

‎Day 4/rearrange-numbers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
l = list(map(int, input('Enter a list of numbers: ').split()))
2+
3+
l1 = [-1] * len(l)
4+
5+
for i in l:
6+
if l[i] >= 0:
7+
l1[l[i]] = l[i]
8+
9+
print(l1)

0 commit comments

Comments
(0)

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