import numpy as np
from scipy.optimize import curve_fit
test_a = 1.7
test_b = -5.689
test_c = 1.2456
def test_sin(x, a, b, c):
return a + b * np.sin(x + c)
if __name__ == '__main__':
x = np.array(range(10))
y = test_sin(x, test_a, test_b, test_c)
params, cov = curve_fit(test_sin, x, y)
print(params)
import urllib
import lxml.etree as etree
def get_xml(url):
response = urllib.urlopen(url)
return response.read()
if __name__ == '__main__':
xml = get_xml('http://www.cbr.ru/scripts/XML_daily.asp?date_req=02/03/2002')
xml_data = etree.fromstring(xml)
bel_rub = xml_data.xpath("/ValCurs/Valute[@ID='R01090']/Value")[0].text
print(bel_rub)