Erster Schwung für Teil 22
This commit is contained in:
42
teil22/calc_array.py
Normal file
42
teil22/calc_array.py
Normal file
@@ -0,0 +1,42 @@
|
||||
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}')
|
||||
|
Reference in New Issue
Block a user