Solve Me First
def solveMeFirst(a,b):
return a+b
num1 = int(input())
num2 = int(input())
res = solveMeFirst(num1,num2)
print(res)
Simple Array Sum
n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
print(sum(arr))
Compare the Triplets
a0,a1,a2 = input().strip().split(' ')
a0,a1,a2 = [int(a0),int(a1),int(a2)]
b0,b1,b2 = input().strip().split(' ')
b0,b1,b2 = [int(b0),int(b1),int(b2)]
array1 = [a0, a1, a2]
array2 = [b0, b1, b2]
sum1 = 0;
sum2 = 0;
for i in range(0, len(array1)):
if array1[i] > array2[i]:
sum1 += 1
if array1[i] < array2[i]:
sum2 += 1
print(sum1, sum2)
A Very Big Sum
n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
summation = 0;
for i in range(0, len(arr)):
summation += arr[i]
print(summation)
Diagonal Difference
n = int(input().strip())
a = []
for a_i in range(n):
a_t = [int(a_temp) for a_temp in input().strip().split(' ')]
a.append(a_t)
sum1 = 0
sum2 = 0
for i in range(0, n):
sum1 += a[i][i]
sum2 +=a[i][(n-1)-i]
print(abs(sum1 - sum2))
Plus Minus
n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
zeroes = 0
positives = 0
negatives = 0
for i in range(n):
if arr[i] > 0:
positives +=1
if arr[i] < 0:
negatives +=1
if arr[i] == 0:
zeroes +=1
print(positives/n)
print(negatives/n)
print(zeroes)
Staircase
#n = int(input().strip())
n = 5
for i in range(1, (n+1)):
print(((n-i) * " ")+(i*"#"))
Mini-Max
a,b,c,d,e = input().strip().split(' ')
a,b,c,d,e = [int(a),int(b),int(c),int(d),int(e)]
sortedList = [a, b, c, d, e]
sortedList.sort()
sum1 = 0
sum2 = 0
for i in range(len(sortedList)-1):
sum1 += sortedList[i]
sum2 += sortedList[i+1]
print(sum1, sum2)
Time Conversion
testString = "12:40:03AM"
newHour = ""
def getHour(string):
h = int(string[0]+string[1])
return h
if (testString[8] == "A"):
if(getHour(testString) == 12):
newHour = "00"
else:
newHour = str(getHour(testString))
if (testString[8] == "P"):
if (getHour(testString) == 12):
newHour = "12"
else:
newHour = str(getHour(testString) + 12)
if(int(newHour) < 10 and newHour != "00"):
newHour = "0"+newHour
print(newHour+testString[2:10])
Birthday Cake Candles
n = int(input().strip())
height = [int(height_temp) for height_temp in input().strip().split(' ')]
count = 0;
biggest = max(height)
for i in range(n):
if height[i] == biggest:
count += 1
print(count)