Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # строка форматного вывода
- # "Страна:%6s, прогноз:%6.3fмлн чел, относительная погрешность:%4.2fпроц."
- import numpy as np
- country=input()
- strk1=input()
- polinom=int(input())
- tourist_2018_fakt=float(input())
- yp=2018 # year_prognoz
- years=[int(i) for i in range(2005, 2018)]
- tourist=[float(i) for i in strk1.split()]
- #print(country)
- #print(len(years), years)
- #print(len(tourist), tourist)
- #print(polinom)
- x_list=years
- y_list=tourist
- #print()
- #print(x_list)
- #print(y_list)
- #print()
- k1_poly=[]
- k2_poly=[]
- k3_poly=[]
- if polinom==1:
- k1_poly = np.polyfit(x_list, y_list, polinom)
- tourist_2018_prognoz=k1_poly[0] * yp + k1_poly[1]
- if polinom==2:
- k2_poly = np.polyfit(x_list, y_list, polinom)
- tourist_2018_prognoz=k2_poly[0] * yp**2 + k2_poly[1]*yp*1+ k2_poly[2]
- if polinom==3:
- k3_poly = np.polyfit(x_list, y_list, polinom)
- tourist_2018_prognoz = k3_poly[0] * yp**3 + k3_poly[1]*yp**2 + k3_poly[2]*yp**1 + k3_poly[3]
- #print()
- #print(tourist_2018_fakt)
- #print(tourist_2018_prognoz)
- #print()
- delta=abs((tourist_2018_fakt-tourist_2018_prognoz)/tourist_2018_fakt)
- #print(delta)
- #print()
- print("Страна:%6s, прогноз:%6.3fмлн чел, относительная погрешность:%4.2fпроц."%(country, tourist_2018_prognoz, delta*100))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement