diff --git a/challenges/week_1/checker.py b/challenges/week_1/checker.py index 50020fc..b90852e 100644 --- a/challenges/week_1/checker.py +++ b/challenges/week_1/checker.py @@ -1,4 +1,4 @@ -import bus_fare_challenge +import bus_fare_challenge as solution import datetime import unittest @@ -12,7 +12,7 @@ def setUp(self) -> None: "Tue": 100, "Wed": 100, "Thu": 100, - "Thu": 100, + "Fri": 100, "Sat": 60, "Sun": 80, } @@ -22,7 +22,7 @@ def test_date(self) -> None: Tests whether the date returned by the program is correct. """ actual = self.date - given = bus_fare_challenge.date + given = solution.date self.assertEqual(actual, given, f"Today's date is Wrong by {given - actual}!") def test_day(self) -> None: @@ -30,7 +30,7 @@ def test_day(self) -> None: Tests whether the day returned by the program is correct. """ actual = self.day - given = bus_fare_challenge.day + given = solution.day self.assertEqual( actual, given, f"Today is wrong, expexted {actual} but got {given}!" ) @@ -40,7 +40,7 @@ def test_fare(self) -> None: Tests whether the fare returned by the program is correct. """ actual = self.charts[self.day] - given = bus_fare_challenge.fare + given = solution.fare self.assertEqual( actual, given, f"Fare is wrong, expected {actual} but got {given}!" ) diff --git a/challenges/week_5/checker.py b/challenges/week_5/checker.py new file mode 100644 index 0000000..edc188c --- /dev/null +++ b/challenges/week_5/checker.py @@ -0,0 +1,62 @@ +import unittest +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +from sklearn.model_selection import train_test_split +from sklearn.linear_model import LinearRegression +from sklearn import metrics +import linear_regression_solution as solution + + +class TestLinearRegressionChallenge(unittest.TestCase): + def setUp(self) -> None: + self.df = pd.read_csv( + "/home/tim/Dev/DS/Learning/python-bootcamp/challenges/week_5/data.csv", + index_col=0, + ) + self.X = np.array(self.df.dropna()["x"]).reshape(-1, 1) + self.y = np.array(self.df.dropna()["y"]).reshape(-1, 1) + self.performance = solution.performance + + def test_prep_data(self) -> None: + actual = self.df.dropna().size + given = solution.clean_data.size + self.assertEqual( + actual, + given, + f"Expected {actual} but got {given}. Please clean your data off null values!", + ) + + def test_feature_shape(self) -> None: + actual = (970, 1) + given = solution.X.shape + self.assertEqual( + actual, + given, + f"Expected {actual} but got {given}. Please reshape your features!", + ) + given = solution.y.shape + self.assertEqual( + actual, + given, + f"Expected {actual} but got {given}. Please reshape your features!", + ) + + def test_model_evaluation(self) -> None: + actual_type = tuple + given_type = type(solution.performance) + self.assertEqual( + actual_type, + given_type, + f"Expected {actual_type} but got {given_type}. Model evaluation fuction should return a tuple!", + ) + + +if __name__ == "__main__": + + print("=========================================================================") + print("=========================================================================") + print("===== Start: Checking ********************************************* =====") + unittest.main(exit=False) + print("===== End: Checking ********************************************* =======") + print("=========================================================================") \ No newline at end of file diff --git a/challenges/week_5/data.csv b/challenges/week_5/data.csv new file mode 100644 index 0000000..3ac91a8 --- /dev/null +++ b/challenges/week_5/data.csv @@ -0,0 +1,1001 @@ +,x,y +0,24.0,21.54945196 +1,50.0,47.46446305 +2,15.0,17.21865634 +3,38.0,36.58639803 +4,87.0,87.28898389 +5,36.0,32.46387493 +6,12.0,10.78089683 +7,81.0,80.76339859999999 +8,25.0,24.61215147 +9,5.0,6.963319071 +10,16.0,11.23757338 +11,16.0,13.53290206 +12,24.0,24.60323899 +13,39.0,39.40049976 +14,54.0,48.43753838 +15,60.0,61.69900319 +16,26.0,26.92832418 +17,73.0,70.40520550000002 +18,29.0,29.34092408 +19,31.0,25.30895192 +20,68.0,69.02934339 +21,87.0,84.99484703 +22,58.0,57.04310305 +23,54.0,50.5921991 +24,84.0,83.02772202 +25,58.0,57.05752706 +26,49.0,47.95883341 +27,20.0,24.34226432 +28,90.0,94.68488281 +29,48.0,48.03970696 +30,4.0,7.08132338 +31,25.0,21.99239907 +32,42.0,42.33151664 +33,0.0,0.329089443 +34,60.0,61.92303698 +35,93.0,91.17716423 +36,39.0,39.45358014 +37,7.0,5.996069607000001 +38,21.0,22.59015942 +39,68.0,61.18044414 +40,84.0,85.02778957 +41,0.0,-1.28631089 +42,58.0,61.94273962 +43,19.0,21.96033347 +44,36.0,33.66194193 +45,19.0,17.60946242 +46,59.0,58.5630564 +47,51.0, +48,19.0,22.136348100000006 +49,33.0,35.07467353 +50,85.0,86.18822311 +51,44.0,42.63227697 +52,5.0,4.09817744 +53,59.0,61.2229864 +54,14.0,17.70677576 +55,9.0,11.85312574 +56,75.0,80.23051695 +57,69.0,62.64931741 +58,10.0,9.616859804 +59,17.0,20.02797699 +60,58.0,61.7510743 +61,74.0,71.61010303 +62,21.0,23.77154623 +63,51.0,51.90142035 +64,19.0,22.66073682 +65,50.0,50.02897927 +66,24.0,26.68794368 +67,0.0,0.376911899 +68,12.0,6.806419002 +69,75.0,77.33986001 +70,21.0,28.90260209 +71,64.0,66.7346608 +72,5.0,0.707510638 +73,58.0,57.07748383 +74,32.0,28.41453196 +75,41.0,44.46272123 +76,7.0,7.459605998 +77,4.0,2.316708112 +78,5.0,4.928546187 +79,49.0,52.50336074 +80,90.0,91.19109623 +81,3.0,8.489164326000001 +82,11.0,6.9633719670000005 +83,32.0,31.97989959 +84,83.0,81.42812049999998 +85,25.0,22.62365422 +86,83.0,78.52505087 +87,26.0,25.80714057 +88,76.0,73.51081775 +89,95.0,91.775467 +90,53.0,49.21863516 +91,77.0,80.50445387 +92,42.0,50.05636123 +93,25.0,25.46292549 +94,54.0,55.32164264 +95,55.0,59.1244888 +96,0.0,1.100686692 +97,73.0,71.98020786 +98,35.0,30.13666408 +99,86.0,83.88427405 +100,90.0,89.91004752 +101,13.0,8.335654576 +102,46.0,47.88388961 +103,46.0,45.00397413 +104,32.0,31.15664574 +105,8.0,9.190375682 +106,71.0,74.83135003 +107,28.0,30.23177607 +108,24.0,24.21914027 +109,56.0, +110,49.0,50.61728392 +111,79.0,78.67470043 +112,90.0,86.236707 +113,89.0,89.10409255 +114,41.0,43.26595082 +115,27.0,26.68273277 +116,58.0,59.46383041 +117,26.0,28.90055826 +118,31.0,31.300416 +119,70.0,71.1433266 +120,71.0,68.47392059999999 +121,39.0,39.98238856 +122,7.0,4.075776144 +123,48.0,47.85817542 +124,56.0,51.20390217 +125,45.0,43.9367213 +126,41.0,38.13626679 +127,3.0,3.574661632 +128,37.0,36.4139958 +129,24.0,22.21908523 +130,68.0,63.53125720000001 +131,47.0,49.86702787 +132,27.0,21.53140009 +133,68.0,64.05710234 +134,74.0,70.77549842 +135,95.0,92.15749762 +136,79.0,81.22259156 +137,21.0,25.10114067 +138,95.0,94.08853397 +139,54.0,53.25166165 +140,56.0,59.16236621 +141,80.0,75.24148428 +142,26.0,28.22325833 +143,25.0,25.33323728 +144,8.0,6.364615702999999 +145,95.0,95.4609216 +146,94.0,88.64183756 +147,54.0,58.70318693 +148,7.0,6.815491279 +149,99.0,99.40394676 +150,36.0,32.77049249 +151,48.0,47.0586788 +152,65.0,60.53321778 +153,42.0,40.30929858 +154,93.0,89.42222685 +155,86.0,86.82132066 +156,26.0,26.11697543 +157,51.0,53.26657596 +158,100.0,96.62327888 +159,94.0,95.78441027 +160,6.0,6.047286687000001 +161,24.0,24.47387908 +162,75.0,75.96844763 +163,7.0,3.829381009 +164,53.0,52.51703683 +165,73.0,72.80457527 +166,16.0,14.10999096 +167,80.0,80.86087062 +168,77.0,77.01988215 +169,89.0,86.26972444 +170,80.0,77.13735466 +171,55.0,51.47649476 +172,19.0,17.34557531 +173,56.0, +174,47.0,44.15029394 +175,56.0,59.24362743 +176,2.0,-1.053275611 +177,82.0,86.79002254 +178,57.0,60.14031858 +179,44.0,44.04222058 +180,26.0,24.5227488 +181,52.0,52.95305521 +182,41.0,43.16133498 +183,44.0,45.67562576 +184,3.0,-2.830749501 +185,31.0,29.19693178 +186,97.0,96.49812401 +187,21.0,22.5453232 +188,17.0,20.10741433 +189,7.0,4.035430253 +190,61.0,61.14568518 +191,10.0,13.97163653 +192,52.0,55.34529893 +193,10.0,12.18441166 +194,65.0,64.00077658 +195,71.0,70.3188322 +196,4.0,-0.936895047 +197,24.0,18.91422276 +198,26.0, +199,51.0,47.5775361 +200,42.0,43.2736092 +201,62.0,66.48278755 +202,74.0,75.72605529 +203,77.0,80.59643338 +204,3.0,-2.235879852 +205,50.0,47.04654956 +206,24.0,21.59635575 +207,37.0,32.87558963 +208,58.0,57.95782956 +209,52.0,52.24760027 +210,27.0,24.58286902 +211,14.0,12.12573805 +212,100.0,100.0158026 +213,3530.15736917, +214,72.0,74.04682658 +215,5.0,1.6119474669999998 +216,71.0,70.36836307 +217,54.0,52.26831735 +218,84.0,83.1286166 +219,42.0,43.64765048 +220,54.0,49.44785426 +221,74.0,72.6356699 +222,54.0,52.78130641 +223,53.0,57.11195136 +224,78.0,79.10506290000002 +225,97.0,101.6228548 +226,49.0,53.5825402 +227,71.0,68.92139297 +228,48.0,46.9666961 +229,51.0,51.02642868 +230,89.0,85.52073551 +231,99.0,99.51685756 +232,93.0,94.63911256 +233,49.0,46.78357742 +234,18.0,21.21321959 +235,65.0,58.37266004 +236,83.0,87.22059677 +237,100.0,102.4967859 +238,41.0,43.88314335 +239,52.0,53.06655757 +240,29.0,26.33464785 +241,97.0,98.52008934 +242,7.0,9.400497579 +243,51.0,52.94026699 +244,58.0,53.83020877 +245,50.0,45.94511142 +246,67.0,65.0132736 +247,89.0, +248,76.0,75.63280796 +249,35.0,36.78035027 +250,99.0,100.5328916 +251,31.0,29.04466136 +252,52.0,51.70352433 +253,11.0,9.199954717999999 +254,66.0,71.70015848 +255,50.0,49.82634062 +256,39.0,37.49971096 +257,60.0,53.65084683 +258,35.0,33.92561965 +259,53.0,49.92639685 +260,14.0,8.148154262 +261,49.0,49.72359037 +262,16.0,16.16712757 +263,76.0,75.30033002 +264,13.0,9.577368567999999 +265,51.0,48.38088357 +266,70.0,72.95331671 +267,98.0,92.59573853 +268,86.0,88.85523586 +269,100.0,99.00361771 +270,46.0,45.09439571 +271,51.0,46.94362684 +272,50.0,48.33449605 +273,91.0,94.92329574 +274,48.0,47.78165248 +275,81.0,81.28960746 +276,38.0,37.83155021 +277,40.0,39.69185252 +278,79.0,76.92664854 +279,96.0,88.02990531 +280,60.0,56.99178872 +281,70.0,72.58929383 +282,44.0,44.98103442 +283,11.0,11.99017641 +284,6.0,1.919513328 +285,5.0,1.6288260730000002 +286,72.0,66.27746655 +287,55.0,57.53887255 +288,95.0,94.70291077 +289,41.0,41.21469904 +290,25.0,25.04169243 +291,1.0,3.778209914 +292,55.0,50.50711779 +293,4.0,9.682408486 +294,48.0,48.88147608 +295,55.0,54.40348599 +296,75.0,71.70233156 +297,68.0,69.35848388 +298,100.0,99.98491591 +299,25.0,26.03323718 +300,75.0,75.48910307 +301,34.0,36.59623056 +302,38.0,40.95102191 +303,92.0,86.78316267 +304,21.0,15.50701184 +305,88.0,85.86077871 +306,75.0,79.20610113 +307,76.0,80.80643766 +308,44.0,48.59717283 +309,10.0,13.93415049 +310,21.0,27.3051179 +311,16.0,14.00226297 +312,32.0,33.67416 +313,13.0,13.11612884 +314,26.0,24.76649193 +315,70.0,73.68477876 +316,77.0,77.53149541 +317,77.0,76.24503196 +318,88.0,88.0578931 +319,35.0,35.02445799 +320,24.0,21.65857739 +321,17.0,17.33681562 +322,91.0,94.36778957 +323,32.0,33.43396307 +324,36.0,32.52179399 +325,89.0,90.57741298 +326,69.0,71.25634126 +327,30.0,31.23212856 +328,6.0,5.3988400610000005 +329,22.0,18.56241391 +330,67.0,71.97121038 +331,9.0,5.225759566 +332,74.0,73.5964342 +333,50.0,49.76948983 +334,85.0,82.69087513 +335,3.0,1.652309089 +336,0.0,-3.836652144 +337,59.0,62.03811556 +338,62.0,61.26514581 +339,17.0,13.24991628 +340,90.0,88.61672694 +341,23.0,21.13655528 +342,19.0,23.85017475 +343,93.0,92.01203405 +344,14.0,10.26712261 +345,58.0,54.14681616 +346,87.0,87.00645713 +347,37.0,37.69447352 +348,20.0,19.62278654 +349,35.0,34.78561007 +350,63.0,62.03190983 +351,56.0,52.67003801 +352,62.0,58.09031476 +353,98.0,97.19448821 +354,90.0,90.50155298 +355,51.0,50.5123462 +356,93.0,94.45211871 +357,22.0,21.10794636 +358,38.0,37.36298431 +359,13.0,10.28574844 +360,98.0, +361,99.0, +362,31.0,30.6063167 +363,94.0,96.19000542 +364,73.0,71.30828034 +365,37.0,34.59311043 +366,23.0,19.02332876 +367,11.0,10.76669688 +368,88.0, +369,47.0,48.71787679 +370,79.0,78.74139764 +371,91.0,85.23492274 +372,71.0,71.65789964 +373,10.0,8.938990554 +374,39.0,39.89606046 +375,92.0,91.85091116 +376,99.0,99.11200375 +377,28.0,26.22196486 +378,32.0,33.21584226 +379,32.0,35.72392691 +380,75.0,76.88604495 +381,99.0,99.30874567 +382,27.0,25.77161074 +383,64.0,67.85169407 +384,98.0,98.50371084 +385,38.0,31.11331895 +386,46.0,45.51171028 +387,13.0,12.65537808 +388,96.0,95.56065366 +389,9.0,9.526431641 +390,34.0,36.10893209 +391,49.0,46.43628318 +392,1.0,-3.83998112 +393,50.0,48.97302037 +394,94.0,93.25305499 +395,27.0,23.47650968 +396,20.0,17.13551132 +397,12.0,14.55896144 +398,45.0,41.53992729 +399,91.0,91.64730552 +400,61.0,66.16652565 +401,10.0,9.230857489 +402,47.0,47.41377893 +403,33.0,34.76441561 +404,84.0,86.10796637 +405,24.0,21.81267954 +406,48.0,48.89963951 +407,48.0,46.78108638 +408,9.0,12.91328547 +409,93.0,94.55203143 +410,99.0,94.97068753 +411,8.0,2.379172481 +412,20.0, +413,38.0,35.79795462 +414,78.0,82.0763803 +415,81.0,78.87097714 +416,42.0,47.2492425 +417,95.0,96.18852325 +418,78.0,78.38491927 +419,44.0,42.94274064 +420,68.0,64.43231595 +421,87.0,84.21191485 +422,58.0,57.3069783 +423,52.0,52.52101436 +424,26.0,25.744024300000003 +425,75.0,75.42283401 +426,48.0,53.62523007 +427,71.0,75.14466308 +428,77.0,74.12151511 +429,34.0,36.24807243 +430,24.0,20.21665898 +431,70.0,66.94758118 +432,29.0,34.07278254 +433,76.0,73.13850045 +434,98.0,92.85929155 +435,28.0,28.36793808 +436,87.0,85.59308727 +437,9.0,10.68453755 +438,87.0,86.10708624 +439,33.0,33.22031418 +440,64.0,66.09563422 +441,17.0,19.30486546 +442,49.0,48.84542083 +443,95.0,93.73176312 +444,75.0,75.45758614 +445,89.0,91.24239226 +446,81.0,87.15690853 +447,25.0,25.53752833 +448,47.0,46.06629478 +449,50.0,49.65277661 +450,5.0,7.382244165 +451,68.0,71.11189935 +452,84.0,83.50570521 +453,8.0,8.791139892999999 +454,41.0,33.30638903 +455,26.0,26.40362524 +456,89.0,91.72960726 +457,78.0,82.53030719 +458,34.0,36.67762733 +459,92.0,86.98450355 +460,27.0,32.34784175 +461,12.0,16.78353974 +462,2.0,1.576584383 +463,22.0,17.4618141 +464,0.0,2.116113029 +465,26.0,24.34804332 +466,50.0,48.29491198 +467,84.0,85.52145453 +468,70.0,73.71434779 +469,66.0,63.15189497 +470,42.0,38.46213684 +471,19.0,19.47100788 +472,94.0,94.07428225 +473,71.0,67.92051286 +474,19.0,22.58096241 +475,16.0,16.01629889 +476,49.0,48.43307886 +477,29.0,29.6673599 +478,29.0,26.65566328 +479,86.0,86.28206739 +480,50.0,50.82304924 +481,86.0,88.57251713 +482,30.0,32.59980745 +483,23.0,21.02469368 +484,20.0,20.72894979 +485,16.0,20.38051187 +486,57.0,57.25180153 +487,8.0,6.967537054 +488,8.0,10.240085 +489,62.0,64.94841088 +490,55.0,55.35893915 +491,30.0,31.24365589 +492,86.0,90.72048818 +493,62.0,58.750127 +494,51.0,55.85003198 +495,61.0,60.19925869 +496,86.0,85.03295412 +497,61.0,60.38823085 +498,21.0,18.44679787 +499,81.0,82.18839247 +500,97.0,94.2963344 +501,5.0,7.682024586 +502,61.0,61.01858089 +503,47.0,53.60562216 +504,98.0,94.47728801 +505,30.0,27.9645947 +506,63.0,62.55662585 +507,0.0,1.406254414 +508,100.0,101.7003412 +509,18.0,13.84973988 +510,30.0,28.99769315 +511,98.0,99.04315693 +512,16.0,15.56135514 +513,22.0,24.63528393 +514,55.0,53.98393374 +515,43.0,42.91449728 +516,75.0,74.29662112 +517,91.0,91.17012883 +518,46.0, +519,85.0,82.47683519 +520,55.0,56.15303953 +521,36.0,37.17063131 +522,49.0,46.36928662 +523,94.0,97.02383456 +524,43.0,40.83182104 +525,22.0,24.08498313 +526,37.0,41.14386358 +527,24.0, +528,95.0,100.740897 +529,61.0,61.19971596 +530,75.0,74.39517002 +531,68.0,69.04377173 +532,58.0,56.68718792 +533,5.0, +534,53.0,55.72021356 +535,80.0,79.22021816 +536,83.0,86.30177517 +537,25.0,25.26971886 +538,34.0,36.33294447 +539,26.0,27.65574228 +540,90.0,94.79690531 +541,60.0,58.67366671 +542,49.0,56.15934471 +543,19.0,18.40919388 +544,92.0,86.26936988 +545,29.0,26.59436195 +546,8.0,8.452520159 +547,57.0,56.18131518 +548,29.0,27.65452669 +549,19.0,20.87391785 +550,81.0,77.83354439 +551,50.0,50.01787825 +552,15.0,9.290856256 +553,70.0,75.02847249999998 +554,39.0,38.3037698 +555,43.0,44.70786405 +556,21.0,22.51016575 +557,98.0,102.4959452 +558,86.0,86.76845244 +559,16.0,13.89748578 +560,25.0,24.81824269 +561,31.0,33.94224862 +562,93.0,92.26970059 +563,67.0,68.73365081 +564,49.0,47.38516883 +565,25.0,32.37576914 +566,88.0,87.67388681 +567,54.0,54.57648371 +568,21.0,18.06450222 +569,8.0,7.896539841 +570,32.0,35.00341078 +571,35.0,36.72823317 +572,67.0,65.84975426 +573,90.0,89.59295492 +574,59.0,61.69026202 +575,15.0,11.60499315 +576,67.0,71.08268029999998 +577,42.0,43.71901164 +578,44.0,41.57421008 +579,77.0,74.25552425 +580,68.0,66.28310437 +581,36.0,36.62438077 +582,11.0,10.32374866 +583,10.0,7.156457657000001 +584,65.0,67.88603132 +585,98.0,101.1097591 +586,98.0,98.6132033 +587,49.0,50.19083844 +588,31.0,27.83896261 +589,56.0,55.9249564 +590,70.0,76.47340872 +591,91.0,92.05756378 +592,25.0,27.35245439 +593,54.0,55.32083476 +594,39.0,41.39990349 +595,91.0,93.59057024 +596,3.0,5.297054029 +597,22.0,21.01429422 +598,2.0,2.267059451 +599,2.0,-0.121860502 +600,65.0,66.49546208 +601,71.0,73.83637687 +602,42.0,42.10140878 +603,76.0,77.35135732 +604,43.0,41.02251779 +605,8.0,14.75305272 +606,86.0,83.28199022 +607,87.0,89.93374342 +608,3.0,2.286571686 +609,58.0,55.61421297 +610,62.0,62.15313408 +611,89.0,89.55803528 +612,95.0,94.00291863 +613,28.0,26.78023848 +614,0.0,-0.764537626 +615,1.0,0.28286600300000003 +616,49.0,44.26800515 +617,21.0,19.85174138 +618,46.0,47.15960005 +619,11.0,8.359366572 +620,89.0,92.08157084 +621,37.0,41.88734051 +622,29.0, +623,44.0,46.87654473 +624,96.0,96.35659485 +625,16.0,17.917069899999994 +626,74.0,71.67949917 +627,35.0,32.64997554 +628,42.0,39.34482965 +629,16.0,17.03401999 +630,56.0,52.87524074 +631,18.0,15.85414849 +632,100.0,108.8716183 +633,54.0, +634,92.0,89.4749477 +635,63.0,63.67348242 +636,81.0,83.78410946 +637,73.0,73.51136922 +638,48.0,46.80297244 +639,1.0,5.809946802000001 +640,85.0,85.23027975 +641,14.0,10.58213964 +642,25.0,21.37698317 +643,45.0,46.0537745 +644,98.0,95.2389253 +645,97.0,94.15149206 +646,58.0,54.54868046 +647,93.0, +648,88.0,88.47741598 +649,89.0,84.48045678 +650,47.0,48.79647071 +651,6.0, +652,34.0,30.48882921 +653,30.0,29.76846185 +654,16.0,13.51574749 +655,86.0,86.12955884 +656,40.0,43.30022747 +657,52.0,51.92110232 +658,15.0,16.49185287 +659,4.0,7.998073432000001 +660,95.0,97.66689567 +661,99.0,89.80545367 +662,35.0,38.07166567 +663,58.0,60.27852322 +664,10.0,6.709195759 +665,16.0,18.35488924 +666,53.0,56.37058203 +667,58.0,62.80064204 +668,42.0,41.25155632 +669,24.0,19.42637541 +670,84.0,82.88935804 +671,64.0,63.61364981 +672,12.0,11.29627199 +673,61.0,60.02274882 +674,75.0,72.60339326 +675,15.0,11.87964573 +676,100.0,100.7012737 +677,43.0,45.12420809 +678,13.0,14.81106804 +679,48.0,48.09368034 +680,45.0,42.29145672 +681,52.0,52.73389794 +682,34.0,36.72396986 +683,30.0,28.64535198 +684,65.0,62.16675273 +685,100.0,95.58459518 +686,67.0,66.04325304 +687,99.0,99.9566225 +688,45.0,46.14941984 +689,87.0,89.13754963 +690,73.0,69.71787806 +691,9.0,12.31736648 +692,81.0,78.20296268 +693,72.0,71.30995371 +694,81.0,81.45544709 +695,58.0,58.59500642 +696,93.0,94.62509374 +697,82.0,88.60376995 +698,66.0, +699,97.0,94.9752655 +0,77.0,79.77515201 +1,21.0,23.17727887 +2,22.0,25.60926156 +3,20.0,17.85738813 +4,36.0,41.84986439 +5,15.0,9.805234876 +6,62.0,58.87465933 +7,95.0,97.61793701 +8,20.0,18.39512747 +9,5.0,8.746747654 +10,4.0,2.811415826 +11,19.0,17.09537241 +12,96.0,95.14907176 +13,62.0,61.38800663 +14,36.0,40.24701716 +15,15.0,14.82248589 +16,65.0,66.95806869 +17,14.0,16.63507984 +18,87.0,90.65513736 +19,69.0,77.22982636 +20,89.0,92.11906278 +21,51.0,46.91387709 +22,89.0,89.82634442 +23,27.0,21.71380347 +24,97.0, +25,58.0,57.01631363 +26,79.0,78.31056542 +27,21.0,19.1315097 +28,93.0,93.03483388 +29,27.0,26.59112396 +30,99.0,97.55155344 +31,31.0,31.43524822 +32,33.0,35.12724777 +33,80.0,78.61042432 +34,28.0,33.07112825 +35,47.0,51.69967172 +36,53.0,53.62235225 +37,69.0,69.46306072 +38,28.0,27.42497237 +39,33.0,36.34644189 +40,91.0,95.06140858 +41,71.0,68.16724757 +42,50.0,50.96155532 +43,76.0,78.04237454 +44,4.0,5.607664865 +45,37.0,36.11334779 +46,70.0,67.23521550000001 +47,68.0,65.01324035 +48,40.0,38.14753871 +49,35.0,34.31141446 +50,94.0,95.28503937 +51,88.0,87.84749912 +52,52.0,54.08170635 +53,31.0,31.93063515 +54,59.0,59.61247085 +55,0.0,-1.040114209 +56,39.0,47.49374765 +57,64.0,62.60089773 +58,69.0,70.9146434 +59,57.0,56.14834113 +60,13.0,14.05572877 +61,72.0,68.11367147 +62,76.0,75.59701346 +63,61.0,59.225745 +64,82.0,85.45504157 +65,18.0,17.76197116 +66,41.0,38.68888682 +67,50.0,50.96343637 +68,55.0,51.83503872 +69,13.0,17.076110699999994 +70,46.0,46.56141773 +71,13.0,10.34754461 +72,79.0,77.91032969 +73,53.0,50.17008622 +74,15.0,13.25690647 +75,28.0,31.32274932 +76,81.0,73.9308764 +77,69.0, +78,52.0,52.01932286 +79,84.0,83.68820499 +80,68.0,70.3698748 +81,27.0, +82,56.0,49.83051801 +83,48.0,49.88226593 +84,40.0,41.04525583 +85,39.0,33.37834391 +86,82.0,81.29750133 +87,100.0,105.5918375 +88,59.0,56.82457013 +89,43.0,48.67252645 +90,67.0,67.02150613 +91,38.0,38.43076389 +92,63.0,58.61466887 +93,91.0,89.12377509 +94,60.0,60.9105427 +95,14.0,13.83959878 +96,21.0,16.89085185 +97,87.0,84.06676818 +98,73.0,70.34969772 +99,32.0,33.38474138 +100,2.0,-1.63296825 +101,82.0,88.54475895 +102,19.0,17.44047622 +103,74.0,75.69298554 +104,42.0,41.97607107 +105,12.0,12.59244741 +106,1.0,0.275307261 +107,90.0,98.13258005 +108,89.0,87.45721555 +109,0.0,-2.344738542 +110,41.0,39.3294153 +111,16.0,16.68715211 +112,94.0,96.58888601 +113,97.0,97.70342201 +114,66.0,67.01715955 +115,24.0, +116,17.0,13.41310757 +117,90.0,95.15647284 +118,13.0,9.744164258 +119,0.0,-3.467883789 +120,64.0,62.82816355 +121,96.0,97.27405461 +122,98.0,95.58017185 +123,12.0,7.468501839 +124,41.0,45.44599591 +125,47.0,46.69013968 +126,78.0,74.4993599 +127,20.0,21.63500655 +128,89.0,91.59548851 +129,29.0,26.49487961 +130,64.0,67.38654703 +131,75.0, +132,12.0,12.07991648 +133,25.0,21.32273728 +134,28.0,29.31770045 +135,30.0,26.48713683 +136,65.0,68.94699774 +137,59.0,59.10598995 +138,64.0,64.37521087 +139,53.0,60.20758349 +140,71.0,70.34329706 +141,97.0,97.1082562 +142,73.0,75.75841779999998 +143,9.0,10.80462727 +144,12.0,12.11219941 +145,63.0,63.28312382 +146,99.0,98.03017721 +147,60.0,63.19354354 +148,35.0,34.8534823 +149,2.0,-2.819913974 +150,60.0,59.83139660000001 +151,32.0,29.38505024 +152,94.0,97.00148372 +153,84.0,85.18657275 +154,63.0,61.74063192 +155,22.0,18.84798163 +156,81.0,78.79008525 +157,93.0,95.12400481 +158,33.0,30.48881287 +159,7.0,10.41468095 +160,42.0,38.98317436 +161,46.0,46.11021062 +162,54.0,52.45103628 +163,16.0,21.16523945 +164,49.0,52.28620611 +165,43.0,44.18863945 +166,95.0,97.13832018 +167,66.0,67.22008001 +168,21.0,18.98322306 +169,35.0,24.3884599 +170,80.0, +171,37.0,40.03504862 +172,54.0,53.32005764 +173,56.0,54.55446979 +174,1.0,-2.761182595 +175,32.0,37.80182795 +176,58.0,57.48741435 +177,32.0,36.06292994 +178,46.0,49.83538167 +179,72.0, +180,17.0,14.86159401 +181,97.0,101.0697879 +182,93.0,99.43577876 +183,91.0,91.69240746 +184,37.0,34.12473248 +185,4.0,6.079390073 +186,54.0,59.07247174 +187,51.0,56.43046022 +188,27.0,30.49412933 +189,46.0,48.35172635 +190,92.0,89.73153611 +191,73.0,72.86282528 +192,77.0,80.97144285 +193,91.0,91.36566374 +194,61.0,60.07137496 +195,99.0,99.87382707 +196,4.0,8.655714172 +197,72.0,69.39858505 +198,19.0,19.38780134 +199,57.0,53.11628433 +200,78.0,78.39683006 +201,26.0, +202,74.0,75.07484683 +203,90.0,92.88772282 +204,66.0,69.45498498 +205,13.0,13.12109842 +206,40.0,48.09843134 +207,77.0,79.3142548 +208,67.0,68.48820749 +209,75.0,73.23008459999998 +210,23.0,24.68362712 +211,45.0,41.90368917 +212,59.0, +213,44.0,45.96396877 +214,23.0,23.52647153 +215,55.0,51.80035866 +216,55.0,51.10774273 +217,95.0,95.79747345 +218,12.0,9.241138977 +219,4.0,7.646529762999999 +220,7.0,9.281699753 +221,100.0,103.5266162 +222,48.0,47.41006725 +223,42.0,42.03835773 +224,96.0,96.11982476 +225,39.0,38.05766408 +226,100.0,105.4503788 +227,87.0,88.80306911 +228,14.0,15.49301141 +229,14.0,12.42624606 +230,37.0,40.00709598 +231,5.0,5.634030902 +232,88.0,87.36938931 +233,91.0,89.73951993 +234,65.0,66.61499643 +235,74.0,72.9138853 +236,56.0,57.19103506 +237,16.0,11.21710477 +238,5.0,0.676076749 +239,28.0, +240,92.0,95.3958003 +241,46.0,52.05490703 +242,54.0,59.70864577 +243,39.0,36.79224762 +244,44.0,37.08457698 +245,31.0,24.18437976 +246,68.0,67.28725332 +247,86.0,82.870594 +248,90.0,89.899991 +249,38.0,36.94173178 +250,21.0,19.87562242 +251,95.0,90.71481654 +252,56.0,61.09367762 +253,60.0,60.11134958 +254,65.0,64.83296316 +255,78.0,81.40381769 +256,89.0,92.40217686 +257,6.0,2.576625376 +258,67.0,63.80768172 +259,36.0,38.67780759 +260,16.0,16.82839701 +261,100.0, +262,45.0,44.68913433 +263,73.0,71.00377824 +264,57.0,51.57326718 +265,20.0,19.87846479 +266,76.0,79.50341495 +267,34.0,34.58876491 +268,55.0,55.73834670000001 +269,72.0,68.19721905 +270,55.0,55.81628509 +271,8.0,9.391416798 +272,56.0,56.01448111 +273,72.0,77.9969477 +274,58.0,55.37049953 +275,6.0,11.89457829 +276,96.0,94.79081712 +277,23.0,25.69041546 +278,58.0,53.52042319 +279,23.0,18.31396758 +280,19.0,21.42637785 +281,25.0,30.41303282 +282,64.0,67.68142149 +283,21.0,17.0854783 +284,59.0,60.91792707 +285,19.0,14.99514319 +286,16.0, +287,42.0,41.46923883 +288,43.0,42.84526108 +289,61.0,59.12912974 +290,92.0,91.30863673 +291,11.0,8.673336357 +292,41.0,39.31485292 +293,1.0,5.313686205 +294,8.0,5.405220517999999 +295,71.0,68.54588790000001 +296,46.0,47.33487629 +297,55.0,54.09063686 +298,62.0,63.29717058 +299,47.0,52.45946688 diff --git a/challenges/week_5/linear_regression_challenge.py b/challenges/week_5/linear_regression_challenge.py new file mode 100644 index 0000000..0b90aa0 --- /dev/null +++ b/challenges/week_5/linear_regression_challenge.py @@ -0,0 +1 @@ +# WRITE YOUR CODE SOLUTION HERE diff --git a/source/week-1/print/input.py b/source/week-1/print/input.py index b840e8b..251ee73 100644 --- a/source/week-1/print/input.py +++ b/source/week-1/print/input.py @@ -1,6 +1,12 @@ -# The input funciton allows you to prompt the user for a value +# The input function allows you to prompt the user to type something # You need to declare a variable to hold the value entered by the user -Name = input('What is your name? ') +# IMPORTANT: When you declare a variable, it has to start with small letter +name = input('What is your name? ') -print('Great, your name is '+ Name) \ No newline at end of file +print('Great, your name is ' + name) + +# The user can type their name on the next line with the \n command / not on the same line as above +name = input("What is your name?\n") + +print('Great, your name is ' + name) diff --git a/source/week-1/print/print.py b/source/week-1/print/print.py index ec50927..8b8ce73 100644 --- a/source/week-1/print/print.py +++ b/source/week-1/print/print.py @@ -5,7 +5,10 @@ print('Hello world single quotes') # Strings can also be enclosed in double quotes -print("Hello world double quotes") +print("Hello world - double quotes") -# using print to display integers -print(188) \ No newline at end of file +# using print to display integer / whole numbers +print(188) + +# using print to display float number / real number +print(99.9) diff --git a/source/week-1/variables/doing_math.py b/source/week-1/variables/doing_math.py index 886a322..34acdbb 100644 --- a/source/week-1/variables/doing_math.py +++ b/source/week-1/variables/doing_math.py @@ -3,7 +3,8 @@ first_num = 6 second_num = 2 -# You can peform a variety of math operations on numeric values +# FIRST WAY OF DOING IT +"""# You can perform a variety of math operations on numeric values print('addition') print(first_num + second_num) print('subtraction') @@ -14,3 +15,29 @@ print(first_num / second_num) print ('exponent') print(first_num ** second_num) +""" + +# SECOND WAY OF DOING IT + +# importing operator module +import operator + +# using add() to add two numbers +print("The addition of numbers is :", end="") +print(operator.add(first_num, second_num)) + +# using sub() to subtract two numbers +print("The difference of numbers is :", end="") +print(operator.sub(first_num, second_num)) + +# using mul() to multiply two numbers +print("The multiplication of numbers is :", end="") +print(operator.mul(first_num, second_num)) + +# using truediv() to divide two numbers +print("The division of numbers is :", end="") +print(operator.truediv(first_num, second_num)) + +# using pow() to find the power of two numbers +print("The power of numbers is :", end="") +print(operator.pow(first_num, second_num)) diff --git a/source/week-1/variables/format_strings.py b/source/week-1/variables/format_strings.py index 6b79588..a6551d3 100644 --- a/source/week-1/variables/format_strings.py +++ b/source/week-1/variables/format_strings.py @@ -1,8 +1,21 @@ +# FIRST WAY +# the capitalize function will return the string with +# the first letter uppercase and the rest of the word lowercase + +# Ask the user for their first and last name // it does not matter how the user types it: +# ALEX, alex, aLEX etc. --> it will be saved in the memory as Alex (Fist letter will be with uppercase) +first_name = input('What is your first name? ').capitalize() +last_name = input('What is your last name? ').capitalize() + +print('Hello ' + first_name + ' ' + last_name) + + +# SECOND WAY # Ask the user for their first and last name first_name = input('What is your first name? ') last_name = input('What is your last name? ') # the capitalize function will return the string with # the first letter uppercase and the rest of the word lowercase -print ('Hello ' + first_name.capitalize() + ' ' \ - + last_name.capitalize()) +print('Hello ' + first_name.capitalize() + ' ' + last_name.capitalize()) +