File tree Expand file tree Collapse file tree 9 files changed +58
-31
lines changed Expand file tree Collapse file tree 9 files changed +58
-31
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
File renamed without changes.
Original file line number Diff line number Diff line change 11def lonelyinteger (a ):
2- b = sorted (a )
3- if len (b )== 1 :
2+ b = sorted (a )
3+ if len (b ) == 1 :
44 return b [0 ]
55 else :
6- for i in range (len (b )):
7- count = 0
6+ for i in range (len (b )):
7+ count = 0
88 for j in range (len (b )):
9- if b [i ]== b [j ]:
10- count += 1
11- if count == 1 :
9+ if b [i ] == b [j ]:
10+ count += 1
11+ if count == 1 :
1212 return b [i ]
13-
14- a = list (map (int ,input ().split ()))
15- print (lonelyinteger (a ))
13+
14+
15+ def lonelyinteger (a ):
16+ b = sorted (a )
17+ data = {}
18+ if len (b ) == 1 :
19+ return b [0 ]
20+ else :
21+ for i in b :
22+ if i in data :
23+ data [i ] += 1
24+ else :
25+ data [i ] = 1
26+ for key , value in data .items ():
27+ if value == 1 :
28+ return key
29+
30+
31+ a = list (map (int , input ().split ()))
32+ print (lonelyinteger (a ))
Original file line number Diff line number Diff line change 11def diagonalDifference (arr ):
22 # Write your code here
3- c = 0
4- d = 0
5- n = len (arr )
3+ c = 0
4+ d = 0
5+ n = len (arr )
66 for i in range (n ):
7- c += arr [i ][i ]
8- d += arr [i ][n - i - 1 ]
7+ c += arr [i ][i ]
8+ d += arr [i ][n - i - 1 ]
99 # a=c-d
10- return abs (c - d )
10+ return abs (c - d )
11+
1112
1213n = int (input ().strip ())
1314
@@ -23,7 +24,7 @@ def diagonalDifference(arr):
2324# For example, the square matrix arr is shown below:
2425# 1 2 3
2526# 4 5 6
26- # 9 8 9
27- # The left-to-right diagonal = 1+5+9 = 15.
28- # The right to left diagonal = 3+5+9=17.
27+ # 9 8 9
28+ # The left-to-right diagonal = 1+5+9 = 15.
29+ # The right to left diagonal = 3+5+9=17.
2930# Their absolute difference is |15-17| = 2.
Original file line number Diff line number Diff line change 11# Find the Percentage of the student name
2- if __name__ == ' __main__' :
2+ if __name__ == " __main__" :
33 n = int (input ())
44 student_marks = {}
55 for _ in range (n ):
66 name , * line = input ().split ()
77 scores = list (map (float , line ))
88 student_marks [name ] = scores
9- query_name = input ()# student name search average
10- i = 0
11- d = student_marks [query_name ]
12- i = sum (d )/ 3
9+ query_name = input () # student name search average
10+ i = 0
11+ d = student_marks [query_name ]
12+ i = sum (d ) / 3
1313
14- print ("%.2f" % i )
14+ print ("%.2f" % i )
1515
16- # using for loop enumerate function
16+ # using for loop enumerate function
1717 # for j,k in enumerate(d):
1818 # i+=k
1919 # i=i/3
Original file line number Diff line number Diff line change 1- if __name__ == ' __main__' :
1+ if __name__ == " __main__" :
22 n = int (input ())
3- arr = map (int , input ().split ())
3+ arr = map (int , input ().split ())
44 print (sorted (list (set (arr )))[- 2 ])
Original file line number Diff line number Diff line change @@ -2,4 +2,6 @@ def hash_tup():
22 n = int (input ())
33 integer_list = map (int , input ().split ())
44 print (hash (tuple (integer_list )))
5- hash_tup ()
5+
6+
7+ hash_tup ()
Original file line number Diff line number Diff line change 1+ def is_leap (year ):
2+ leap = False
3+ if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0 ):
4+ leap = True
5+ return leap
6+
7+
8+ year = int (input ())
9+ print (is_leap (year ))
You can’t perform that action at this time.
0 commit comments