Hallo,
ich möchte eine Matrix mit Zufallszahlen füllen und diese auf eine Kommastelle runden
Kann jemand helfen?
mein Plan:
import numpy as np
t=np.random.rand(2,3)
print("t=",t)
u=round(t,1) #hier erscheint Fehlermeldung
Matrix mit Zufallszahlen füllen und runden
-
Kobra23759
- User
- Beiträge: 61
- Registriert: Donnerstag 9. April 2020, 18:47
sorry
hat sich erledigt es muß np.round heißen
hat sich erledigt es muß np.round heißen
- __blackjack__
- User
- Beiträge: 14330
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
Oder die Methode auf dem Array-Objekt verwenden.
Code: Alles auswählen
import numpy as np
def main():
print(np.random.default_rng().random((2, 3)).round(1))
if __name__ == "__main__":
main()„Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.“ — Brian W. Kernighan
