fork download
  1. # Python program for study of libraries statistics, math, numpy and scipy
  2.  
  3. import statistics
  4. import math
  5. import numpy as np
  6. from scipy.special import comb
  7. from scipy.special import perm
  8. from scipy.special import logsumexp
  9.  
  10. data = [10,20,30,40,50]
  11.  
  12. # using statistics library
  13. mean = statistics.mean(data)
  14. median= statistics.median(data)
  15. mode = statistics.mode(data)
  16. gm= statistics.geometric_mean(data)
  17. hm= statistics.harmonic_mean(data)
  18.  
  19. print(f"Mean: {mean}")
  20. print(f"Median: {median}")
  21. print(f"Mode: {mode}")
  22. print(f"Geometric Mean : {gm}")
  23. print(f"Harmonic Mean : {hm}")
  24.  
  25. # using math library
  26. x = math.sqrt(49)
  27. y=math.cbrt(64)
  28. z = math.ceil(1.4)
  29. w= math.floor(1.4)
  30.  
  31. print(f" Square Root of 49 is : {x}")
  32. print(f" Cube Root of 64 is : {y}")
  33. print(f" ceil value : {z}")
  34. print(f"Floor value : {w}")
  35.  
  36. # using numpy library
  37. product = np.prod(data)
  38. total= np.sum(data)
  39. s = np.sin(data)
  40. c= np.cos(data)
  41.  
  42. print(f" Product of array elements is {product}")
  43. print(f" Sum of array elements is {total}")
  44. print(f" Sine of array elements are {s}")
  45. print(f" Cosine of array elements are {c}")
  46.  
  47. # using scipy library
  48. cb= comb(9,2)
  49. pr= perm(5,4)
  50. lg =logsumexp(data)
  51.  
  52. print(f" Combinatioons : {cb}")
  53. print(f" Permutations : {pr}")
  54. print(f" Log Sum Exponential of given array is {lg}")
  55.  
  56.  
Success #stdin #stdout 1.33s 53820KB
stdin
Standard input is empty
stdout
Mean: 30
Median: 30
Mode: 10
Geometric Mean : 26.051710846973528
Harmonic Mean : 21.8978102189781
 Square Root  of 49  is : 7.0
 Cube Root  of 64  is : 4.0
 ceil  value : 2
Floor value : 1
 Product of array elements is  12000000
 Sum of array elements is  150
 Sine of array elements are  [-0.54402111  0.91294525 -0.98803162  0.74511316 -0.26237485]
 Cosine of array elements are  [-0.83907153  0.40808206  0.15425145 -0.66693806  0.96496603]
 Combinatioons  : 36.0
 Permutations : 120.0
 Log Sum Exponential of given array is  50.00004540096037