Skip to content

Instantly share code, notes, and snippets.

@Mancek
Mancek / matrixSum.py
Last active July 6, 2021 21:19
Sum of even numbers in 3x3 matrix
import numpy as np
def sumEvenNumbersInMatrix(matrix):
return sum(matrix[matrix%2==0])
rows = 3
columns = 3
#Example input
# 1 2 3
@Mancek
Mancek / sumOdd.py
Last active July 4, 2021 07:43
Sum odd numbers
def sumOdd(lowerLimit, upperlimit):
return sum(range(lowerLimit if lowerLimit%2 else lowerLimit+1,upperLimit,2))
lowerLimit = int(input())
upperLimit = int(input())
print (sumOdd(lowerLimit,upperLimit))