Question
sumMatrix(numMat) Function that sums the elements of a Matrix represented as a nested list of integers. (Python Language) All input values are taken from the
sumMatrix(numMat) Function that sums the elements of a Matrix represented as a nested list of integers. (Python Language)
All input values are taken from the user.
Sample code: (this function finds the greater of 4 number, I need a fuction that sums the elements of a Matrix represented as a nested list of integers)
# Function Name: greatestOfFour
# Desc: Finds greatest of 4 numbers
# Parameters: num1-int, num2-int, num3-int, num4-int
# Return: int
defgreatestOfFour(num1, num2, num3, num4):
if num1>num2>num3>num4:
return num1
elif num2>num3>num4:
return num2
elif num3>num4:
return num3
else:
return num4
# Test Code
# Initialize Variables
num1=num2=num3=num4 = 0
# Read Input
print("Enter four numbers to check the greatest: ")
num1 =input("1st num: ")
num2 =input("2nd num: ")
num3 =input("3rd num: ")
num4 =input("4th num: ")
# Call function for Process and Output
print("Greatest of 4 numbers: ", greatestOfFour(int(num1),int(num2),int(num3),int(num4)))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started