-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython_practice
More file actions
131 lines (101 loc) · 3.16 KB
/
python_practice
File metadata and controls
131 lines (101 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Lists:
if __name__ == '__main__':
N = int(raw_input())
Integer_list=list()
for i in range(1,N):
command = raw_input().split()
#print(command)
if command[0]=="insert":
Integer_list.insert(int(command[1]),int(command[2]))
elif command[0]=="print":
print Integer_list
elif command[0]=="remove":
Integer_list.remove(int(command[1]))
elif command[0]=="append":
Integer_list.append(int(command[1]))
elif command[0]=="sort":
Integer_list.sort()
elif command[0]=="pop":
Integer_list.pop()
elif command[0]=="reverse":
Integer_list.reverse()
#print(Integer_list)
Tuples:
if __name__ == '__main__':
n = int(raw_input())
integer_list = map(int, raw_input().split())
#print(integer_list)
tup1=tuple(integer_list)
#h=hash(tup1)
print(hash(tup1))
#print(hash(integer_list))
#print second largest in list
if __name__ == '__main__':
n = int(raw_input())
arr = map(int, raw_input().split())
'''
set1=set(arr)
#print(set1)
arr2=list(set1)
arr2.sort()
#print(arr2)
print(arr2[len(arr2)-2])
'''
print max(list(filter(lambda i: i!=max(arr),arr)))
#print student name Alphabetically who secured 2nd minimum score
students_list=[]
for _ in range(int(raw_input())):
name = raw_input()
score = float(raw_input())
students_list.append([name,score])
#print(students_list)
score_list=[row[1] for row in students_list]
#print(score_list)
min_list=[]
for i in students_list:
if i[1]!=min(score_list):
min_list.append([i[0],i[1]])
#print(min_list)
min_list.sort(key= lambda x: x[1])
#print(min_list)
sec_low=min_list[0][1]
min_list.sort(key= lambda x: x[0])
#print(min_list)
for i in min_list:
if i[1]==sec_low:
print(i[0])
#LEAP YEAR CHECK
def is_leap(year):
leap = False
# Write your logic here
#A leap year is exactly divisible by 4 except for century years (years ending with 00).
#But The century year is a leap year only if it is perfectly divisible by 400.
#for Every 4 years --> one leap year
#century year can not be leap year unleass it it is 400th century year
#most of times century year can not be leap year
#But For Every four hundred years--> century year is leap year
#divisible by 4 and also century year ; check if divisible by 400 --> leap
#divisible by 4 and also century year ; check if not divisible by 400--> not leap
#divisible by 4 and also not century year ; no need to check with 400 --> leap
#not divisible by 4 ; no need to check with 100 and 400 --> not leap
if year%4==0 :
if year%100==0 :
if year%400==0 :
leap=True
else:
leap=False
else:
leap=True
else:
leap=False
return leap
#print formatting:
from __future__ import print_function
#import sys
if __name__ == '__main__':
n = int(raw_input())
Int_list=[]
for i in range(1,n+1):
Int_list.append(i)
print(*Int_list,sep='',end='\n');
#print(*Int_list,sep='',end='\n',file=sys.stdout);