Advertisement
Resonati

cecyliaa

Jun 26th, 2019
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. def suma(n):
  4. a=0
  5. for i in range(n):
  6. a=a+i
  7. return a
  8. b=suma(10)
  9. print(b)
  10.  
  11. import numpy as np
  12. import pandas as pd
  13.  
  14. oceny=[
  15. ['Monika', 'Nowakowska','3'],
  16. ['Michal', 'Rusc', '5']
  17. ]
  18. trojki=[oceny[i] for i in range(len(oceny)) if oceny[i][2]=='3']
  19. print(trojki)
  20.  
  21. class Pojazd:
  22. def __init__(self, nazwa, kolor, rodzaj, wartosc):
  23. self.nazwa=nazwa
  24. self.kolor=kolor
  25. self.rodzaj=rodzaj
  26. self.wartosc=wartosc
  27. def info(self):
  28. print('Nazwa:'+ str(self.nazwa)+'kolor:'+str(self.kolor)+'rodzaj:'+str(self.rodzaj)+'wartosc:'+str(self.wartosc))
  29. Auto1=Pojazd('Ferrari', "czerwone", 'kabriolet', "5000")
  30. Pojazd.info(Auto1)
  31.  
  32. def slowniki(wejscie : str):
  33. slownik={}
  34. for i in wejscie:
  35. slownik[i]=wejscie.count(i)
  36. print(slownik)
  37.  
  38. slowniki('informatyka')
  39. class Kierownik:
  40. def __init__(self,imie : str, nazwisko : str, staz : int):
  41. self.imie=imie
  42. self.nazwisko=nazwisko
  43. self.staz=staz
  44. self.pensja=3200+self.staz*250
  45. def info(self):
  46. print("#"+self.imie+"#"+self.nazwisko)
  47. stefan = Kierownik("Stefan","Kowalski",250)
  48. stefan.info()
  49.  
  50. def horner(x,*argv):
  51. suma = 0
  52. for i in range(len(argv)-1,-1,-1):
  53. suma=x*suma+argv[i]
  54. return suma
  55. def horner2(x,*argv):
  56. suma = 0
  57. for i in range(len(argv)):
  58. suma=suma+((x**i)*argv[i])
  59. return suma
  60. print(horner(22222,5,1,5,3))
  61. print(horner(1,1,1,1,1))
  62. print(horner2(22222,5,1,5,3))
  63. print(horner2(1,1,1,1,1))
  64. import numpy as np
  65. import pandas as pd
  66. import matplotlib as mpl
  67. import matplotlib.pyplot as plt
  68. from mpl_toolkits.mplot3d import Axes3D
  69. plik = pd.read_csv("miasta.csv",sep=';')
  70. print(plik)
  71. for i in range(len(plik)):
  72. plik['Ludnosc'][i] = int(plik['Ludnosc'][i].replace(' ',''))
  73. plik['Powierzchnia'][i] = float(plik['Powierzchnia'][i].replace(',','.'))
  74. print(plik)
  75. plik.insert(loc=3,column='Gestosc',value=plik['Ludnosc']/plik['Powierzchnia'])
  76. print(plik.sort_values(['Powierzchnia']).head(1))
  77.  
  78. import matplotlib as mpl
  79. import numpy as np
  80. from matplotlib import pyplot as plt
  81. import matplotlib.ticker as ticker
  82. from mpl_toolkits.mplot3d import Axes3D as ax
  83. x = np.arange(-17,17,0.1)
  84. y = np.sin(x)+12*x**2
  85. wykres = plt.plot(x,y,label='sin(x)+12*x^2')
  86. plt.title('tytul')
  87. plt.xlabel('os x')
  88. plt.ylabel('os y')
  89. plt.axis()
  90. plt.legend()
  91. plt.xticks([-17,-17/2,0,17/2,17])
  92. plt.yticks([0,200,400,600,800])
  93. plt.ylim(0,800)
  94. plt.show()
  95. x2=np.arange(-27,27,0.1)
  96. y2=np.arange(-27,27,0.1)
  97. fig = plt.figure()
  98. ax = fig.gca(projection='3d')
  99. ax.plot(x2,y2,(1/np.tan(x2))*y2+(1/np.tan(y2))*x2,label='wykres')
  100. ax.set_xticks([-27,-27/2,0,27/2,27])
  101. ax.set_yticks([-27,-27/2,0,27/2,27])
  102. ax.set_zticks([-3750,-1625,0,1625,3750])
  103. ax.set_xlabel('os x')
  104. ax.set_ylabel('os y')
  105. ax.set_zlabel('os z')
  106. ax.set_title('tytul')
  107. ax.legend()
  108. plt.show()
  109.  
  110. ew
  111. wykres=x.plot.bar(label="Utarg")
  112. plt.legend("Chuj")
  113. plt.xlabel("Sprzedawca")
  114. plt.ylabel("Utarg")
  115. plt.title("Największy utarg w poszczególynch latach")
  116. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement