Alle Dateien aus dem Pythonkurs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
706 B

import numpy as np
# Array initialisieren
org = np.array([1,2,3,4,5,6])
# Kopiert das int64 Array in ein float64 Array
def copy_to_float64(source):
liste = []
for i in range(source.shape[1]):
liste.append(float(source[i]))
return np.array(liste,dtype=float64)
# Ein paar Kopien anlegen
copy_sum = org.copy()
copy_mult = org.copy()
copy_diff = org.copy()
copy_div = org.astype(np.float64).copy()
# Zu allen Elementen 2 dazuzählen
copy_sum += 2
print(f'copy_sum={copy_sum}')
# Alle Elemente mit 2 multiplizieren
copy_mult *= 2
print(f'copy_mult={copy_mult}')
# Von allen Elementen 1 abziehen
copy_diff -= 1
print(f'copy_diff={copy_diff}')
copy_div /=2
print(f'copy_div={copy_div}')