Skip to content

Instantly share code, notes, and snippets.

@nithikan
Last active April 12, 2018 06:37
Show Gist options
  • Save nithikan/dbb0f9991fa9a68a04df8bff81e66c71 to your computer and use it in GitHub Desktop.
Save nithikan/dbb0f9991fa9a68a04df8bff81e66c71 to your computer and use it in GitHub Desktop.
##### Exercise 2 Write a function that creates an array based on the function parameter.
##### Function will populate the array with consecutive numbers, then scale them.
##### 12/04/2018
##### Nithikan Srinakrung - Bam
##### DFL, FTSM, UKM
import numpy as np
import time
def scale_number (a,b):
d = []
s = time.time()
for i in range(a):
c = (i*b)
d.append(c)
print(time.time()-s)
return d
def scale_number2 (a,b):
d = np.zeros(a)
s = time.time()
for i in range(a):
c = (i*b)
d[i]= c
print(time.time()-s)
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment