vendredi 12 février 2021

matrixes to find data greater and lesser than a variable

My doubt is that I can't find a way to get it to show me the values present in the matrix greater and lesser than the variable "mediatot". I appreciate your help

import numpy as np
ñ=0
fil = int (2)#Sucursal
col = int (3)#Dia
matriz=[]

for i in range (fil):
  matriz.append([])
  for j in range (col):
    if j == 0:
      p = str("Lunes")
      j+1
    if j == 1:
      p = str("Martes")
      j+1
    if j == 2:
      p = str("Miercoles")
      j+1
    if j == 3:
      p = str("Jueves")
      j+1
    if j == 4:
      p = str("Viernes")
      j+1
    if j == 5:
      p = str("Sabado")
      j+1
    if j == 6:
      p = str("Domingo")
      j+1
    valor = int (input("Sucursal {}, dia {} : ".format(i+1,p)))
    matriz [i].append(valor)
def Mostrar():
  print()
  for fila in matriz:
    print("\t[",end="")
    for elemento in fila:
      print("",(elemento),"",end="")
    print("]")
  print()
  o=(np.apply_along_axis(sum, 0, matriz))#columnas
  medcol = o.mean()  
  print ("La media de la semana es:",medcol)

Mostrar()
p=(np.apply_along_axis(sum, 1, matriz))#fila
#medfil = p.mean()  
print ("La media de cada sede es:",(p/col))

print(type(matriz))
dr= np.array(matriz)
print(type(dr))
mediatot = dr.mean()  
print("La media de la empresa es:",mediatot)

Aucun commentaire:

Enregistrer un commentaire