Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1.  

     

    Code Block
    matrix = [[1,3,-3,5,23],[23,1,34,13,32],[33,67,64,5,-9],[46,-6,6,64,8],[2,3,19,12,-4]]	
    
  2.  

     

    Code Block
    matrix = [[1,3,-3,5,23],[23,1,34,13,32],[33,67,64,5,-9],[46,-6,6,64,8],[2,3,19,12,-4]]	
     
    for k in range (0,len(matrix)):
    	for t in range (0,len(matrix[k])):
    		if (matrix[k][t]<0)
    			matrix[k][t]*= -1
    print(matrix)

     

     


  3. Code Block
    languagepython
    def max_matrix(matrix):
    	matrix = [[1,3,-3,5,23],[23,1,34,13,32],[33,67,64,5,-9],[46,-6,6,64,8],[2,3,19,12,-4]]	
     
    max = -float('Inf')
    	for i in range(0,len(matrix)):
    		for j in range(0,len(matrix[i])):
    			if (matrix[i][j] > max):
    				max = matrix[i][j]
    	return max
    mat = [[1,3,-3,5,23],[23,1,34,13,32],[33,67,64,5,-9],[46,-6,6,64,8],[2,3,19,12,-4]]	 
    print(max_matrix(mat))

Oppgave 9 - Badekaret

Code Block
languagepython
capacity = 20
currentLevel = 5
while currentLevel < capacity:
    currentLevel += 1    
    print('Current water level is', currentLevel, 'liters.')
print('The bath is full and contains', currentLevel, 'litres.')

...