Created
July 28, 2019 22:17
-
-
Save theSekyi/5dd341bc67db5473405c4d729b9a0400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from math import pi,sin | |
def sinc(my_list_of_x): | |
''' | |
http://mathworld.wolfram.com/SincFunction.html | |
''' | |
y_list = [] | |
for x in my_list_of_x: | |
if x == 0: | |
x = 1 | |
y_value = sin(x)/x | |
y_list.append(y_value) | |
return y_list | |
x = np.linspace(-20,20,20) | |
y = sinc(x) | |
plt.plot(x,y) | |
plt.title('Sinc function') | |
plt.ylabel("y axis") | |
plt.xlabel("x-axis") | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from statistics import median | |
def list_generated(x,y): | |
lst = np.linspace(x,y,50) | |
lst_rounded = [int(round(x)) for x in lst] | |
min_value = min(lst_rounded) | |
max_value = max(lst_rounded) | |
median_value = median(lst_rounded) | |
print(f"The minimum,maximum and median values are {min_value},{max_value},{median_value} and the list in descending order is {sorted(lst_rounded,reverse=True)}") | |
list_generated(100,534) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment