Skip to content

Commit ada0f3a

Browse files
Add files via upload
1 parent ec78aff commit ada0f3a

20 files changed

+242
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if __name__ == '__main__':
2+
n = int(input())
3+
arr = list(set(map(int, input().split())))
4+
5+
arr.sort()
6+
print(arr[-2])
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if __name__ == '__main__':
2+
n = int(input())
3+
student_marks = {}
4+
for _ in range(n):
5+
line = input().split()
6+
student_marks[line[0]] = list(map(float, line[1:]))
7+
print('%.2f'.format(sum(student_marks[input()]) / 3))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if __name__ == '__main__':
2+
x = int(input())
3+
y = int(input())
4+
z = int(input())
5+
n = int(input())
6+
7+
output= []
8+
xyx = []
9+
10+
for X in range(x+1):
11+
for Y in range(y+1):
12+
for Z in range(z + 1):
13+
if X+Y+Z != n:
14+
xyz = [X,Y,Z]
15+
output.append(xyz)
16+
17+
print(output)

02 - Basic Data Types/Lists.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
if __name__ == '__main__':
2+
N = int(input())
3+
Output = [];
4+
for i in range(0,N):
5+
ip = input().split();
6+
if ip[0] == "print":
7+
print(Output)
8+
elif ip[0] == "insert":
9+
Output.insert(int(ip[1]),int(ip[2]))
10+
elif ip[0] == "remove":
11+
Output.remove(int(ip[1]))
12+
elif ip[0] == "pop":
13+
Output.pop();
14+
elif ip[0] == "append":
15+
Output.append(int(ip[1]))
16+
elif ip[0] == "sort":
17+
Output.sort();
18+
else:
19+
Output.reverse();

02 - Basic Data Types/Nested Lists.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
if __name__ == '__main__':
2+
score_list = {}
3+
for _ in range(int(input())):
4+
name = input()
5+
score = float(input())
6+
7+
if score in score_list:
8+
score_list[score].append(name)
9+
else:
10+
score_list[score] = [name]
11+
12+
name_list = []
13+
14+
for i in score_list:
15+
name_list.append([i, score_list[i]])
16+
name_list.sort()
17+
result = name_list[1][1]
18+
result.sort()
19+
print(*result, sep="\n")

02 - Basic Data Types/Tuples.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if __name__ == '__main__':
2+
n = int(input())
3+
integer_list = map(int, input().split())
4+
5+
t = tuple(integer_list)
6+
print(hash(t))

03 - Strings/Alphabet Rangoli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import string
2+
3+
alpha = string.ascii_lowercase
4+
5+
def print_rangoli(size):
6+
# your code goes here
7+
lst = []
8+
for row in range(size):
9+
to_print = "-".join(alpha[row:size])
10+
lst.append(to_print[::-1] + to_print[1:])
11+
width = len(lst[0])
12+
13+
for row in range(size - 1, 0 ,-1):
14+
print(lst[row].center(width, "-"))
15+
16+
for row in range(size):
17+
print(lst[row].center(width, "-"))
18+
19+
20+

03 - Strings/Capitalize.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Complete the solve function below.
2+
def solve(s):
3+
for i in s.split():
4+
s = s.replace(i, i.capitalize())
5+
return s

03 - Strings/Designer Door Mat.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT
2+
if __name__ == '__main__':
3+
N, M = map(int,input().split())
4+
5+
for i in range(1,N,2):
6+
print((".|."*i).center(M,'-'))
7+
print('WELCOME'.center(M,'-'))
8+
for i in range(N-2,-1,-2):
9+
print((".|."*i).center(M,'-'))

03 - Strings/Find a string.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def count_substring(string, sub_string):
2+
count = 0
3+
for i in range(len(string)):
4+
if string[i:].startswith(sub_string):
5+
count += 1
6+
return (count)
7+
8+
9+
if __name__ == '__main__':
10+
string = input().strip()
11+
sub_string = input().strip()
12+
13+
count = count_substring(string, sub_string)
14+
print(count)

0 commit comments

Comments
 (0)