commit 369a584badd19b20cd0744b6a852d5ae0ff1a956 Author: Starnakin Date: Tue Dec 3 14:59:19 2024 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a69c76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +venv +test.txt +*.pyc \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d971528 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Calculateur inflation +Simple calculteur d'inflation de 1980 a 2001 + +## Installation +```sh +python -m venv venv +source venv/bin/activate +pip install -r requirements.txt +``` + +## Usage + +```sh +python main.py +``` + + +## Screenshots +![](./screenshoots/image.png) + +## Source +- Les donnees sur l'inflation dans le fichier [inflation.txt](./inflation.txt) viennent de ce [site](https://france-inflation.com/inflation-depuis-1901.php). +- Les donnees sur le montant du SMIC viennent du site [smic.txt](https://www.cdg17.fr/download/Paie/Notes/valeur_smic_2024-01.pdf) \ No newline at end of file diff --git a/inflation.py b/inflation.py new file mode 100644 index 0000000..cb1c297 --- /dev/null +++ b/inflation.py @@ -0,0 +1,12 @@ +content: str + +with open("inflation.txt") as f: + content = f.read() + +def get_inflation_data() -> dict[str: float]: + inflation_data: dict[str: float] = {} + for line in content.splitlines(): + year, value, _ = line.split(" ") + value = value[:-1] + inflation_data.update({year: float(value) / 100}) + return inflation_data \ No newline at end of file diff --git a/inflation.txt b/inflation.txt new file mode 100644 index 0000000..74c00bc --- /dev/null +++ b/inflation.txt @@ -0,0 +1,123 @@ +2023 4.9% 2936 +2022 5.2% 2799 +2021 1.6% 2661 +2020 0.5 % 2619 +2019 1.1 % 2606 +2018 1.8 % 2577 +2017 1 % 2531 +2016 0.2 % 2505 +2015 0 % 2500 +2014 0.5 % 2499 +2013 0.9 % 2487 +2012 2 % 2465 +2011 2.1 % 2418 +2010 1.5 % 2368 +2009 0.1 % 2332 +2008 2.8 % 2330 +2007 1.5 % 2267 +2006 1.6 % 2233 +2005 1.9 % 2198 +2004 2.1 % 2158 +2003 2.1 % 2113 +2002 2 % 2070 +2001 1.6 % 2030 +2000 1.7 % 1998 +1999 0.5 % 1965 +1998 0.6 % 1955 +1997 1.2 % 1943 +1996 2 % 1920 +1995 1.9 % 1883 +1994 1.7 % 1848 +1993 2.1 % 1818 +1992 2.3 % 1780 +1991 3.3 % 1740 +1990 3.4 % 1685 +1989 3.6 % 1630 +1988 2.7 % 1573 +1987 3.1 % 1532 +1986 2.7 % 1485 +1985 5.8 % 1447 +1984 7.4 % 1367 +1983 9.6 % 1273 +1982 11.8 % 1161 +1981 13.4 % 1039 +1980 13.6 % 916 +1979 10.8 % 807 +1978 9.1 % 728 +1977 9.4 % 668 +1976 9.6 % 611 +1975 11.8 % 557 +1974 13.7 % 498 +1973 9.2 % 438 +1972 6.2 % 401 +1971 5.7 % 378 +1970 5.2 % 358 +1969 6.5 % 340 +1968 4.5 % 319 +1967 2.7 % 306 +1966 2.7 % 297 +1965 2.5 % 290 +1964 3.4 % 283 +1963 4.8 % 273 +1962 4.8 % 261 +1961 3.3 % 249 +1960 3.6 % 241 +1959 6.2 % 232 +1958 15.1 % 219 +1957 3 % 190 +1956 4.2 % 185 +1955 1 % 177 +1954 0.4 % 176 +1953 -1.7 % 175 +1952 11.9 % 178 +1951 16.2 % 159 +1950 10 % 137 +1949 13.2 % 124 +1948 58.7 % 110 +1947 49.2 % 69 +1946 52.6 % 46 +1945 48.5 % 30 +1944 22.2 % 21 +1943 24.1 % 17 +1942 20.3 % 14 +1941 17.5 % 11 +1940 17.8 % 10 +1939 7 % 8 +1938 13.7 % 8 +1937 25.7 % 7 +1936 7.7 % 5 +1935 -8.5 % 5 +1934 -4.1 % 6 +1933 -3.9 % 6 +1932 -8.3 % 6 +1931 -4.5 % 6 +1930 1.1 % 7 +1929 6.1 % 7 +1928 0 % 6 +1927 3.8 % 6 +1926 31.7 % 6 +1925 7.2 % 5 +1924 14.2 % 4 +1923 8.9 % 4 +1922 -2.1 % 4 +1921 -13.3 % 4 +1920 39.5 % 4 +1919 22.6 % 3 +1918 29.2 % 2 +1917 20 % 2 +1916 11.2 % 2 +1915 19.8 % 1 +1914 0 % 1 +1913 0 % 1 +1912 0 % 1 +1911 15.5 % 1 +1910 0 % 1 +1909 0 % 1 +1908 0 % 1 +1907 8.5 % 1 +1906 -7.9 % 1 +1905 0 % 1 +1904 0 % 1 +1903 0 % 1 +1902 0 % 1 +1901 0 % 1 diff --git a/main.py b/main.py new file mode 100644 index 0000000..14750df --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +from tabulate import tabulate + +from inflation import get_inflation_data +from smic import get_smic_data + +start_year: str = input("année de depart: ") +stop_year: str = input("année de de fin: ") + +total_inflation = 1 +inflation_data = get_inflation_data() +smic_data = get_smic_data() + +data: list[list[str]] = [] + +for current_year in range(int(start_year), int(stop_year) + 1): + year: str = str(current_year) + inflation: float = inflation_data.get(year) + smic: float = smic_data.get(year) + data.append([year, str(smic), str(inflation), str(total_inflation * (1 + inflation)), f"{total_inflation} * (1 + {inflation})"]) + total_inflation: float = total_inflation * (1 + inflation) + +head: list[str] = ["année actuelle", "smic", "inflation", "inflation depuis année de depart", "calcul"] + +print(tabulate(data, headers=head, tablefmt="grid")) +print(f"augmentation du smic: +{round((smic_data.get(stop_year) - smic_data.get(start_year)) * 100 / smic_data.get(start_year), 2)}%") +print(f"produit de l'inflation: +{round((total_inflation - 1) * 100, 2)}%") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a00a1bb --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +tabulate==0.9.0 diff --git a/screenshoots/image.png b/screenshoots/image.png new file mode 100644 index 0000000..48b9bb9 Binary files /dev/null and b/screenshoots/image.png differ diff --git a/smic.py b/smic.py new file mode 100644 index 0000000..aca8007 --- /dev/null +++ b/smic.py @@ -0,0 +1,12 @@ +content: str + +with open("smic.txt") as f: + content = f.read() + +def get_smic_data() -> dict[str: float]: + smic_data: dict[str: float] = {} + for line in content.splitlines(): + year, _, _, _, _, value = line.split(" ") + value = value.replace(",", ".") + smic_data.update({year: float(value)}) + return smic_data \ No newline at end of file diff --git a/smic.txt b/smic.txt new file mode 100644 index 0000000..88e3c95 --- /dev/null +++ b/smic.txt @@ -0,0 +1,49 @@ +2001 43,72 7 388,68 29/06/2001 6,67 +2000 42,02 7 101,38 30/06/2000 6,41 +1999 40,72 6 881,68 02/07/1999 6,21 +1998 40,22 6 797,18 26/06/1998 6,13 +1997 39,43 6 663,67 27/06/1997 6,01 +1996 37,91 6 406,79 28/06/1996 5,78 +1996 37,72 6 374,68 28/04/1996 5,75 +1995 36,98 6 249,62 30/06/1995 5,64 +1994 35,56 6 009,64 01/07/1994 5,42 +1993 34,83 5 886,27 06/07/1993 5,31 +1992 34,06 5 756,14 03/07/1992 5,19 +1992 33,31 5 629,39 28/02/1992 5,08 +1991 32,66 5 519,54 29/06/1991 4,98 +1990 31,94 5 397,86 30/11/1990 4,87 +1990 31,28 5 286,32 30/06/1990 4,77 +1990 30,51 5 156,19 31/03/1990 4,65 +1989 29,91 5 054,79 01/07/1989 4,56 +1989 29,36 4 961,84 01/03/1989 4,48 +1988 28,76 4 860,44 01/07/1988 4,38 +1988 28,48 4 813,12 01/06/1988 4,34 +1987 27,84 4 704,96 01/07/1987 4,24 +1987 27,57 4 659,33 01/03/1987 4,2 +1986 26,92 4 549,48 07/07/1986 4,1 +1986 26,59 4 493,71 01/06/1986 4,05 +1985 26,04 4 400,76 01/07/1985 3,97 +1985 25,54 4 316,26 01/05/1985 3,89 +1985 24,9 4 208,10 01/04/1985 3,8 +1984 24,36 4 116,84 01/11/1984 3,71 +1984 23,84 4 028,96 01/07/1984 3,63 +1984 23,56 3 981,64 01/05/1984 3,59 +1984 22,78 3 849,82 01/01/1984 3,47 +1983 22,33 3 773,77 01/10/1983 3,4 +1983 21,89 3 699,41 01/07/1983 3,34 +1983 21,65 3 658,85 01/06/1983 3,3 +1983 21,02 3 552,38 01/03/1983 3,2 +1982 20,29 3 429,01 01/12/1982 3,09 +1982 19,64 3 319,16 01/07/1982 2,99 +1982 19,03 3 215,07 01/05/1982 2,9 +1982 18,62 3 146,78 01/03/1982 2,84 +1982 18,15 3 145,94 01/01/1982 2,77 +1981 17,76 3 078,34 01/11/1981 2,71 +1981 17,34 3 005,54 01/09/1981 2,64 +1981 16,72 2 898,08 01/06/1981 2,55 +1981 15,2 2 634,62 01/06/1981 2,32 +1980 14,79 2 563,55 01/12/1980 2,25 +1980 14,29 2 476,89 01/09/1980 2,18 +1980 14 2 426,62 01/07/1980 2,13 +1980 13,66 2 367,69 01/05/1980 2,08 +1980 13,37 2 317,42 01/03/1980 2,04 \ No newline at end of file