diff --git a/even-more-python-for-beginners-data-tools/03 - Intro to Pandas/03 - Pandas Series and DataFrame.ipynb b/even-more-python-for-beginners-data-tools/03 - Intro to Pandas/03 - Pandas Series and DataFrame.ipynb index e1802f1e..21ee33ea 100644 --- a/even-more-python-for-beginners-data-tools/03 - Intro to Pandas/03 - Pandas Series and DataFrame.ipynb +++ b/even-more-python-for-beginners-data-tools/03 - Intro to Pandas/03 - Pandas Series and DataFrame.ipynb @@ -56,15 +56,17 @@ } ], "source": [ - "airports = pd.Series([\n", - " 'Seattle-Tacoma', \n", - " 'Dulles', \n", - " 'London Heathrow', \n", - " 'Schiphol', \n", - " 'Changi', \n", - " 'Pearson', \n", - " 'Narita'\n", - " ])\n", + "airports = pd.Series(\n", + " [\n", + " 'Seattle-Tacoma', \n", + " 'Dulles', \n", + " 'London Heathrow', \n", + " 'Schiphol', \n", + " 'Changi', \n", + " 'Pearson', \n", + " 'Narita'\n", + " ]\n", + ")\n", "\n", "# When using a notebook, you can use the print statement\n", "# print(airports) to examine the contents of a variable\n", @@ -235,15 +237,17 @@ } ], "source": [ - "airports = pd.DataFrame([\n", - " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", - " ['Dulles', 'Washington', 'USA'],\n", - " ['London Heathrow', 'London', 'United Kingdom'],\n", - " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", - " ['Changi', 'Singapore', 'Singapore'],\n", - " ['Pearson', 'Toronto', 'Canada'],\n", - " ['Narita', 'Tokyo', 'Japan']\n", - " ])\n", + "airports = pd.DataFrame(\n", + " [\n", + " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", + " ['Dulles', 'Washington', 'USA'],\n", + " ['London Heathrow', 'London', 'United Kingdom'],\n", + " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", + " ['Changi', 'Singapore', 'Singapore'],\n", + " ['Pearson', 'Toronto', 'Canada'],\n", + " ['Narita', 'Tokyo', 'Japan']\n", + " ]\n", + ")\n", "\n", "airports" ] @@ -350,17 +354,18 @@ } ], "source": [ - "airports = pd.DataFrame([\n", - " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", - " ['Dulles', 'Washington', 'USA'],\n", - " ['London Heathrow', 'London', 'United Kingdom'],\n", - " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", - " ['Changi', 'Singapore', 'Singapore'],\n", - " ['Pearson', 'Toronto', 'Canada'],\n", - " ['Narita', 'Tokyo', 'Japan']\n", - " ],\n", - " columns = ['Name', 'City', 'Country']\n", - " )\n", + "airports = pd.DataFrame(\n", + " [\n", + " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", + " ['Dulles', 'Washington', 'USA'],\n", + " ['London Heathrow', 'London', 'United Kingdom'],\n", + " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", + " ['Changi', 'Singapore', 'Singapore'],\n", + " ['Pearson', 'Toronto', 'Canada'],\n", + " ['Narita', 'Tokyo', 'Japan']\n", + " ],\n", + " columns = ['Name', 'City', 'Country']\n", + ")\n", "\n", "airports " ] diff --git a/even-more-python-for-beginners-data-tools/04 - Examining Pandas DataFrame contents/04 - Exploring pandas DataFrame contents.ipynb b/even-more-python-for-beginners-data-tools/04 - Examining Pandas DataFrame contents/04 - Exploring pandas DataFrame contents.ipynb index 0f508386..7fa553fc 100644 --- a/even-more-python-for-beginners-data-tools/04 - Examining Pandas DataFrame contents/04 - Exploring pandas DataFrame contents.ipynb +++ b/even-more-python-for-beginners-data-tools/04 - Examining Pandas DataFrame contents/04 - Exploring pandas DataFrame contents.ipynb @@ -114,17 +114,18 @@ } ], "source": [ - "airports = pd.DataFrame([\n", - " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", - " ['Dulles', 'Washington', 'USA'],\n", - " ['Heathrow', 'London', 'United Kingdom'],\n", - " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", - " ['Changi', 'Singapore', 'Singapore'],\n", - " ['Pearson', 'Toronto', 'Canada'],\n", - " ['Narita', 'Tokyo', 'Japan']\n", - " ],\n", - " columns = ['Name', 'City', 'Country']\n", - " )\n", + "airports = pd.DataFrame(\n", + " [\n", + " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", + " ['Dulles', 'Washington', 'USA'],\n", + " ['Heathrow', 'London', 'United Kingdom'],\n", + " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", + " ['Changi', 'Singapore', 'Singapore'],\n", + " ['Pearson', 'Toronto', 'Canada'],\n", + " ['Narita', 'Tokyo', 'Japan']\n", + " ],\n", + " columns = ['Name', 'City', 'Country']\n", + ")\n", "\n", "airports " ] diff --git a/even-more-python-for-beginners-data-tools/05 - Query a pandas Dataframe/05 - Querying DataFrames.ipynb b/even-more-python-for-beginners-data-tools/05 - Query a pandas Dataframe/05 - Querying DataFrames.ipynb index 95e80218..3f7a533a 100644 --- a/even-more-python-for-beginners-data-tools/05 - Query a pandas Dataframe/05 - Querying DataFrames.ipynb +++ b/even-more-python-for-beginners-data-tools/05 - Query a pandas Dataframe/05 - Querying DataFrames.ipynb @@ -115,17 +115,18 @@ } ], "source": [ - "airports = pd.DataFrame([\n", - " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", - " ['Dulles', 'Washington', 'USA'],\n", - " ['London Heathrow', 'London', 'United Kingdom'],\n", - " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", - " ['Changi', 'Singapore', 'Singapore'],\n", - " ['Pearson', 'Toronto', 'Canada'],\n", - " ['Narita', 'Tokyo', 'Japan']\n", - " ],\n", - " columns = ['Name', 'City', 'Country']\n", - " )\n", + "airports = pd.DataFrame(\n", + " [\n", + " ['Seatte-Tacoma', 'Seattle', 'USA'],\n", + " ['Dulles', 'Washington', 'USA'],\n", + " ['London Heathrow', 'London', 'United Kingdom'],\n", + " ['Schiphol', 'Amsterdam', 'Netherlands'],\n", + " ['Changi', 'Singapore', 'Singapore'],\n", + " ['Pearson', 'Toronto', 'Canada'],\n", + " ['Narita', 'Tokyo', 'Japan']\n", + " ],\n", + " columns = ['Name', 'City', 'Country']\n", + ")\n", "airports " ] }, diff --git a/even-more-python-for-beginners-data-tools/07 - Read and write CSV files from pandas DataFrames/07 - Read write CSV files.ipynb b/even-more-python-for-beginners-data-tools/07 - Read and write CSV files from pandas DataFrames/07 - Read write CSV files.ipynb index 9e164e37..a3c3289e 100644 --- a/even-more-python-for-beginners-data-tools/07 - Read and write CSV files from pandas DataFrames/07 - Read write CSV files.ipynb +++ b/even-more-python-for-beginners-data-tools/07 - Read and write CSV files from pandas DataFrames/07 - Read write CSV files.ipynb @@ -289,9 +289,9 @@ ], "source": [ "airports_df = pd.read_csv(\n", - " 'Data/airportsInvalidRows.csv', \n", - " error_bad_lines=False\n", - " )\n", + " 'Data/airportsInvalidRows.csv', \n", + " error_bad_lines=False\n", + ")\n", "airports_df" ] }, @@ -508,9 +508,9 @@ ], "source": [ "airports_df = pd.read_csv(\n", - " 'Data/airportsNoHeaderRows.csv', \n", - " header=None\n", - " )\n", + " 'Data/airportsNoHeaderRows.csv', \n", + " header=None\n", + ")\n", "airports_df" ] }, @@ -617,10 +617,10 @@ ], "source": [ "airports_df = pd.read_csv(\n", - " 'Data/airportsNoHeaderRows.csv', \n", - " header=None, \n", - " names=['Name', 'City', 'Country']\n", - " )\n", + " 'Data/airportsNoHeaderRows.csv', \n", + " header=None, \n", + " names=['Name', 'City', 'Country']\n", + ")\n", "airports_df" ] }, @@ -873,9 +873,9 @@ "outputs": [], "source": [ "airports_df.to_csv(\n", - " 'Data/MyNewCSVFileNoIndex.csv', \n", - " index=False\n", - " )" + " 'Data/MyNewCSVFileNoIndex.csv', \n", + " index=False\n", + ")" ] } ], @@ -900,4 +900,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/even-more-python-for-beginners-data-tools/08 - Removing and splitting DataFrame columns/08 - Removing columns.ipynb b/even-more-python-for-beginners-data-tools/08 - Removing and splitting DataFrame columns/08 - Removing columns.ipynb index 3133f081..caf90dc6 100644 --- a/even-more-python-for-beginners-data-tools/08 - Removing and splitting DataFrame columns/08 - Removing columns.ipynb +++ b/even-more-python-for-beginners-data-tools/08 - Removing and splitting DataFrame columns/08 - Removing columns.ipynb @@ -576,7 +576,10 @@ "# Remove the column ARR_TIME from the DataFrame delays_df\n", "\n", "#delays_df = delays_df.drop(['ARR_TIME'],axis=1)\n", - "delays_df.drop(columns=['ARR_TIME'], inplace=True)\n", + "delays_df.drop(\n", + " columns=['ARR_TIME'], \n", + " inplace=True\n", + ")\n", "delays_df.head()" ] }, @@ -631,4 +634,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/even-more-python-for-beginners-data-tools/10 - Splitting test and training data with scikit-learn/10 - Train Test split.ipynb b/even-more-python-for-beginners-data-tools/10 - Splitting test and training data with scikit-learn/10 - Train Test split.ipynb index 7739ac56..bbb055b8 100644 --- a/even-more-python-for-beginners-data-tools/10 - Splitting test and training data with scikit-learn/10 - Train Test split.ipynb +++ b/even-more-python-for-beginners-data-tools/10 - Splitting test and training data with scikit-learn/10 - Train Test split.ipynb @@ -250,11 +250,11 @@ "from sklearn.model_selection import train_test_split\n", "\n", "X_train, X_test, y_train, y_test = train_test_split(\n", - " X, \n", - " y, \n", - " test_size=0.3, \n", - " random_state=42\n", - " )" + " X, \n", + " y, \n", + " test_size=0.3, \n", + " random_state=42\n", + ")" ] }, { @@ -575,4 +575,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/even-more-python-for-beginners-data-tools/11 - Train a linear regression model with scikit-learn/11 - Train a basic model.ipynb b/even-more-python-for-beginners-data-tools/11 - Train a linear regression model with scikit-learn/11 - Train a basic model.ipynb index f510507e..5d1e1da2 100644 --- a/even-more-python-for-beginners-data-tools/11 - Train a linear regression model with scikit-learn/11 - Train a basic model.ipynb +++ b/even-more-python-for-beginners-data-tools/11 - Train a linear regression model with scikit-learn/11 - Train a basic model.ipynb @@ -47,11 +47,11 @@ "\n", "# Split our data into test and training DataFrames\n", "X_train, X_test, y_train, y_test = train_test_split(\n", - " X, \n", - " y, \n", - " test_size=0.3, \n", - " random_state=42\n", - " )" + " X, \n", + " y, \n", + " test_size=0.3, \n", + " random_state=42\n", + ")" ] }, { diff --git a/even-more-python-for-beginners-data-tools/12 - Testing a model/12 - Test a model.ipynb b/even-more-python-for-beginners-data-tools/12 - Testing a model/12 - Test a model.ipynb index dd660859..07879e34 100644 --- a/even-more-python-for-beginners-data-tools/12 - Testing a model/12 - Test a model.ipynb +++ b/even-more-python-for-beginners-data-tools/12 - Testing a model/12 - Test a model.ipynb @@ -57,11 +57,11 @@ "\n", "# Split our data into test and training DataFrames\n", "X_train, X_test, y_train, y_test = train_test_split(\n", - " X, \n", - " y, \n", - " test_size=0.3, \n", - " random_state=42\n", - " )\n", + " X, \n", + " y, \n", + " test_size=0.3, \n", + " random_state=42\n", + ")\n", "regressor = LinearRegression() # Create a scikit learn LinearRegression object\n", "regressor.fit(X_train, y_train) # Use the fit method to train the model using your training data" ] diff --git a/even-more-python-for-beginners-data-tools/13 - Evaluating accuracy of a model using calculations/13 - Evaluate accuracy.ipynb b/even-more-python-for-beginners-data-tools/13 - Evaluating accuracy of a model using calculations/13 - Evaluate accuracy.ipynb index a075fe9b..ca3c3b1d 100644 --- a/even-more-python-for-beginners-data-tools/13 - Evaluating accuracy of a model using calculations/13 - Evaluate accuracy.ipynb +++ b/even-more-python-for-beginners-data-tools/13 - Evaluating accuracy of a model using calculations/13 - Evaluate accuracy.ipynb @@ -48,11 +48,11 @@ "\n", "# Split our data into test and training DataFrames\n", "X_train, X_test, y_train, y_test = train_test_split(\n", - " X, \n", - " y, \n", - " test_size=0.3, \n", - " random_state=42\n", - " )\n", + " X, \n", + " y, \n", + " test_size=0.3, \n", + " random_state=42\n", + ")\n", "regressor = LinearRegression() # Create a scikit learn LinearRegression object\n", "regressor.fit(X_train, y_train) # Use the fit method to train the model using your training data\n", "\n", diff --git a/even-more-python-for-beginners-data-tools/14 - NumPy vs Pandas/14 - Working with numpy and pandas.ipynb b/even-more-python-for-beginners-data-tools/14 - NumPy vs Pandas/14 - Working with numpy and pandas.ipynb index 03456ae5..2ff3d5b4 100644 --- a/even-more-python-for-beginners-data-tools/14 - NumPy vs Pandas/14 - Working with numpy and pandas.ipynb +++ b/even-more-python-for-beginners-data-tools/14 - NumPy vs Pandas/14 - Working with numpy and pandas.ipynb @@ -47,10 +47,12 @@ "y = delays_df.loc[:,['ARR_DELAY']] \n", "\n", "# Split our data into test and training DataFrames\n", - "X_train, X_test, y_train, y_test = train_test_split(X, \n", - " y, \n", - " test_size=0.3, \n", - " random_state=42)\n", + "X_train, X_test, y_train, y_test = train_test_split(\n", + " X, \n", + " y, \n", + " test_size=0.3, \n", + " random_state=42\n", + ")\n", "regressor = LinearRegression() # Create a scikit learn LinearRegression object\n", "regressor.fit(X_train, y_train) # Use the fit method to train the model using your training data\n", "\n", @@ -550,10 +552,13 @@ } ], "source": [ - "airports_array = np.array([\n", - " ['YYZ','Pearson'],\n", - " ['SIN','Changi'],\n", - " ['NRT','Narita']])\n", + "airports_array = np.array(\n", + " [\n", + " ['YYZ','Pearson'],\n", + " ['SIN','Changi'],\n", + " ['NRT','Narita']\n", + " ]\n", + ")\n", "print(airports_array)\n", "print(airports_array[0,0])" ] diff --git a/even-more-python-for-beginners-data-tools/15 - Visualizing data with Matplotlib/15 - Visualizing correlations.ipynb b/even-more-python-for-beginners-data-tools/15 - Visualizing data with Matplotlib/15 - Visualizing correlations.ipynb index b5e35ca5..8b3a11b5 100644 --- a/even-more-python-for-beginners-data-tools/15 - Visualizing data with Matplotlib/15 - Visualizing correlations.ipynb +++ b/even-more-python-for-beginners-data-tools/15 - Visualizing data with Matplotlib/15 - Visualizing correlations.ipynb @@ -2,18 +2,14 @@ "cells": [ { "cell_type": "markdown", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Visualizing data with matplotlib" ] }, { "cell_type": "markdown", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "Somtimes graphs provide the best way to visualize data\n", "\n", @@ -43,9 +39,7 @@ }, { "cell_type": "markdown", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "In order to display plots we need to import the **matplotlib** library" ] @@ -61,9 +55,7 @@ }, { "cell_type": "markdown", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "A common plot used in data science is the scatter plot for checking the relationship between two columns\n", "If you see dots scattered everywhere, there is no correlation between the two columns\n", @@ -88,13 +80,13 @@ "source": [ "#Check if there is a relationship between the distance of a flight and how late the flight arrives\n", "delays_df.plot(\n", - " kind='scatter',\n", - " x='DISTANCE',\n", - " y='ARR_DELAY',\n", - " color='blue',\n", - " alpha=0.3,\n", - " title='Correlation of arrival and distance'\n", - " )\n", + " kind='scatter',\n", + " x='DISTANCE',\n", + " y='ARR_DELAY',\n", + " color='blue',\n", + " alpha=0.3,\n", + " title='Correlation of arrival and distance'\n", + ")\n", "plt.show()" ] }, @@ -106,21 +98,19 @@ "source": [ "#Check if there is a relationship between the how late the flight leaves and how late the flight arrives\n", "delays_df.plot(\n", - " kind='scatter',\n", - " x='DEP_DELAY',\n", - " y='ARR_DELAY',\n", - " color='blue',\n", - " alpha=0.3,\n", - " title='Correlation of arrival and departure delay'\n", - " )\n", + " kind='scatter',\n", + " x='DEP_DELAY',\n", + " y='ARR_DELAY',\n", + " color='blue',\n", + " alpha=0.3,\n", + " title='Correlation of arrival and departure delay'\n", + ")\n", "plt.show()" ] }, { "cell_type": "markdown", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "The scatter plot allows us to see there is no correlation between distance and arrival delay but there is a strong correlation between departure delay and arrival delay.\n" ] @@ -147,4 +137,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} diff --git a/more-python-for-beginners/01 - Formatting and linting/bad.py b/more-python-for-beginners/01 - Formatting and linting/bad.py index 4f14bfd4..04175796 100644 --- a/more-python-for-beginners/01 - Formatting and linting/bad.py +++ b/more-python-for-beginners/01 - Formatting and linting/bad.py @@ -1,11 +1,11 @@ x = 12 if x == 24: - print('Is valid') + print('Is valid') else: - print("Not valid") + print("Not valid") def helper(name='sample'): pass def another(name = 'sample'): - pass + pass diff --git a/more-python-for-beginners/01 - Formatting and linting/good.py b/more-python-for-beginners/01 - Formatting and linting/good.py index 3faba59a..f15b011c 100644 --- a/more-python-for-beginners/01 - Formatting and linting/good.py +++ b/more-python-for-beginners/01 - Formatting and linting/good.py @@ -2,9 +2,9 @@ def print_hello(name: str) -> str: """ Greets the user by name - Parameters: - name (str): The name of the user - Returns: - str: The greeting - """ - print('Hello, ' + name) + Parameters: + name (str): The name of the user + Returns: + str: The greeting + """ + print('Hello, ' + name) diff --git a/more-python-for-beginners/02 - Lambdas/failed_sort.py b/more-python-for-beginners/02 - Lambdas/failed_sort.py index fdcd6b07..09a182e6 100644 --- a/more-python-for-beginners/02 - Lambdas/failed_sort.py +++ b/more-python-for-beginners/02 - Lambdas/failed_sort.py @@ -1,8 +1,8 @@ # This code will return an error because the sort method does not know # which presenter field to use when sorting presenters = [ - {'name': 'Susan', 'age': 50}, - {'name': 'Christopher', 'age': 47} + {'name':'Susan', 'age':50}, + {'name':'Christopher', 'age':47} ] presenters.sort() diff --git a/more-python-for-beginners/02 - Lambdas/lambda_sorter.py b/more-python-for-beginners/02 - Lambdas/lambda_sorter.py index ad7878f5..4bb59472 100644 --- a/more-python-for-beginners/02 - Lambdas/lambda_sorter.py +++ b/more-python-for-beginners/02 - Lambdas/lambda_sorter.py @@ -1,14 +1,14 @@ # Sort alphabetically presenters = [ - {'name': 'Susan', 'age': 50}, - {'name': 'Christopher', 'age': 47} + {'name':'Susan', 'age':50}, + {'name':'Christopher', 'age':47} ] -presenters.sort(key=lambda item: item['name']) +presenters.sort(key=lambda item:item['name']) print('-- alphabetically --') print(presenters) # Sort by length of name (shortest to longest) -presenters.sort(key=lambda item: len(item['name'])) +presenters.sort(key=lambda item:len(item['name'])) print('-- length --') print(presenters) diff --git a/more-python-for-beginners/02 - Lambdas/method_sorter.py b/more-python-for-beginners/02 - Lambdas/method_sorter.py index 40f296c6..2b409bc2 100644 --- a/more-python-for-beginners/02 - Lambdas/method_sorter.py +++ b/more-python-for-beginners/02 - Lambdas/method_sorter.py @@ -3,8 +3,8 @@ def sorter(item): presenters = [ - {'name': 'Susan', 'age': 50}, - {'name': 'Christopher', 'age': 47} + {'name':'Susan', 'age':50}, + {'name':'Christopher', 'age':47} ] presenters.sort(key=sorter) print(presenters) diff --git a/more-python-for-beginners/03 - Classes/basic_class.py b/more-python-for-beginners/03 - Classes/basic_class.py index 74576195..56e17275 100644 --- a/more-python-for-beginners/03 - Classes/basic_class.py +++ b/more-python-for-beginners/03 - Classes/basic_class.py @@ -1,11 +1,11 @@ class Presenter(): - def __init__(self, name): - # Constructor - self.name = name - def say_hello(self): - # method - print('Hello, ' + self.name) + def __init__(self, name): + # Constructor + self.name = name + def say_hello(self): + # method + print('Hello, ' + self.name) presenter = Presenter('Chris') presenter.name = 'Christopher' -presenter.say_hello() \ No newline at end of file +presenter.say_hello() diff --git a/more-python-for-beginners/03 - Classes/properties_class.py b/more-python-for-beginners/03 - Classes/properties_class.py index df259cb3..64b89a0e 100644 --- a/more-python-for-beginners/03 - Classes/properties_class.py +++ b/more-python-for-beginners/03 - Classes/properties_class.py @@ -1,18 +1,18 @@ class Presenter(): - def __init__(self, name): - # Constructor - self.name = name + def __init__(self, name): + # Constructor + self.name = name - @property - def name(self): - print('Retrieving name...') - return self.__name - @name.setter - def name(self, value): - # cool validation here - print('Validating name...') - self.__name = value + @property + def name(self): + print('Retrieving name...') + return self.__name + @name.setter + def name(self, value): + # cool validation here + print('Validating name...') + self.__name = value presenter = Presenter('Chris') presenter.name = 'Christopher' -print(presenter.name) \ No newline at end of file +print(presenter.name) diff --git a/more-python-for-beginners/04 - Inheritance/demo.py b/more-python-for-beginners/04 - Inheritance/demo.py index c1983f8f..703b03e8 100644 --- a/more-python-for-beginners/04 - Inheritance/demo.py +++ b/more-python-for-beginners/04 - Inheritance/demo.py @@ -1,15 +1,15 @@ class Person: - def __init__(self, name): - self.name = name - def say_hello(self): - print('Hello, ' + self.name) + def __init__(self, name): + self.name = name + def say_hello(self): + print('Hello, ' + self.name) class Student(Person): - def __init__(self, name, school): - super().__init__(name) - self.school = school - def sing_school_song(self): - print('Ode to ' + self.school) + def __init__(self, name, school): + super().__init__(name) + self.school = school + def sing_school_song(self): + print('Ode to ' + self.school) student = Student('Christopher', 'UVM') student.say_hello() diff --git a/more-python-for-beginners/05 - Mixins/demo.py b/more-python-for-beginners/05 - Mixins/demo.py index 7b5732b6..6aff03f7 100644 --- a/more-python-for-beginners/05 - Mixins/demo.py +++ b/more-python-for-beginners/05 - Mixins/demo.py @@ -15,7 +15,7 @@ def __init__(self): super().__init__() self.title = 'Sql Connection Demo' self.server = 'Some_Server' - + def framework(item): if isinstance(item, Connection): diff --git a/more-python-for-beginners/06 - Managing the file system/files.py b/more-python-for-beginners/06 - Managing the file system/files.py index 45a72b17..fa723db7 100644 --- a/more-python-for-beginners/06 - Managing the file system/files.py +++ b/more-python-for-beginners/06 - Managing the file system/files.py @@ -13,4 +13,4 @@ print('\nfile folder: ' + demo_file.parent.name) # Get the size -print('\nfile size: ' + str(demo_file.stat().st_size) + '\n') \ No newline at end of file +print('\nfile size: ' + str(demo_file.stat().st_size) + '\n') diff --git a/more-python-for-beginners/06 - Managing the file system/paths.py b/more-python-for-beginners/06 - Managing the file system/paths.py index f74a51d0..d18cc3d4 100644 --- a/more-python-for-beginners/06 - Managing the file system/paths.py +++ b/more-python-for-beginners/06 - Managing the file system/paths.py @@ -11,4 +11,4 @@ print('\nFull path:\n' + str(new_file)) # Check if file exists -print('\nDoes that file exist? ' + str(new_file.exists()) + '\n') \ No newline at end of file +print('\nDoes that file exist? ' + str(new_file.exists()) + '\n') diff --git a/more-python-for-beginners/07 - Reading and writing files/read.py b/more-python-for-beginners/07 - Reading and writing files/read.py index 2c612b49..9317a87a 100644 --- a/more-python-for-beginners/07 - Reading and writing files/read.py +++ b/more-python-for-beginners/07 - Reading and writing files/read.py @@ -3,4 +3,4 @@ print('\nIs this readable? ' + str(stream.readable())) print('\nRead one character : ' + stream.read(1)) print('\nRead to end of line : ' + stream.readline()) -print('\nRead all lines to end of file :\n' + str(stream.readlines())+ '\n') \ No newline at end of file +print('\nRead all lines to end of file :\n' + str(stream.readlines())+ '\n') diff --git a/more-python-for-beginners/08 - Managing external resources/demo.py b/more-python-for-beginners/08 - Managing external resources/demo.py index 06955800..796925c5 100644 --- a/more-python-for-beginners/08 - Managing external resources/demo.py +++ b/more-python-for-beginners/08 - Managing external resources/demo.py @@ -1,8 +1,8 @@ try: - stream = open('output.txt', 'wt') - stream.write('Lorem ipsum dolar') + stream = open('output.txt', 'wt') + stream.write('Lorem ipsum dolar') finally: - stream.close() # THIS IS REALLY IMPORTANT!! + stream.close() # THIS IS REALLY IMPORTANT!! # with open('output.txt', 'wt') as stream: -# stream.write('Lorem ipsum dolar') +# stream.write('Lorem ipsum dolar') diff --git a/python-for-beginners/04 - String variables/format_strings.py b/python-for-beginners/04 - String variables/format_strings.py index 6b795886..c892cffd 100644 --- a/python-for-beginners/04 - String variables/format_strings.py +++ b/python-for-beginners/04 - String variables/format_strings.py @@ -4,5 +4,8 @@ # 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() +) diff --git a/python-for-beginners/07 - Error handling/syntax.py b/python-for-beginners/07 - Error handling/syntax.py index 2f113952..8a6a8579 100644 --- a/python-for-beginners/07 - Error handling/syntax.py +++ b/python-for-beginners/07 - Error handling/syntax.py @@ -1,4 +1,4 @@ x = 42 y = 206 if x == y - print('Success') \ No newline at end of file + print('Success') diff --git a/python-for-beginners/08 - Handling conditions/add_else.py b/python-for-beginners/08 - Handling conditions/add_else.py index a7b40ebf..1b260bf7 100644 --- a/python-for-beginners/08 - Handling conditions/add_else.py +++ b/python-for-beginners/08 - Handling conditions/add_else.py @@ -2,14 +2,14 @@ price = float(price) if price >= 1.00: - # Anything that costs $1.00 or more is charged 7% tax - # All statements indented are only executed if price is > = 1 - tax = .07 - print('Tax rate is: ' + str(tax)) + # Anything that costs $1.00 or more is charged 7% tax + # All statements indented are only executed if price is > = 1 + tax = .07 + print('Tax rate is: ' + str(tax)) else: - # Anything else we do not charge any tax - # All statements indented are only executed if price is NOT >= 1 - tax = 0 - print('Tax rate is: ' + str(tax)) + # Anything else we do not charge any tax + # All statements indented are only executed if price is NOT >= 1 + tax = 0 + print('Tax rate is: ' + str(tax)) diff --git a/python-for-beginners/08 - Handling conditions/add_else_different_indentation.py b/python-for-beginners/08 - Handling conditions/add_else_different_indentation.py index 8573d024..3fb049e1 100644 --- a/python-for-beginners/08 - Handling conditions/add_else_different_indentation.py +++ b/python-for-beginners/08 - Handling conditions/add_else_different_indentation.py @@ -1,8 +1,8 @@ price = 5.0 if price >= 1.00: - tax = .07 + tax = .07 else: - tax = 0 + tax = 0 # the print statement below is not indented so is executed after the if # statement is evaluated print(tax) diff --git a/python-for-beginners/08 - Handling conditions/case_insensitive_comparisons.py b/python-for-beginners/08 - Handling conditions/case_insensitive_comparisons.py index f7db49c4..14bee541 100644 --- a/python-for-beginners/08 - Handling conditions/case_insensitive_comparisons.py +++ b/python-for-beginners/08 - Handling conditions/case_insensitive_comparisons.py @@ -3,6 +3,6 @@ # that is all lowercase letters I make the comparison case-insensitive # If someone types in CANADA or Canada it will still be a match if country.lower() == 'canada': - print('Hello eh') + print('Hello eh') else: - print('Hello') + print('Hello') diff --git a/python-for-beginners/08 - Handling conditions/check_tax.py b/python-for-beginners/08 - Handling conditions/check_tax.py index 4aa9b235..7002b4f1 100644 --- a/python-for-beginners/08 - Handling conditions/check_tax.py +++ b/python-for-beginners/08 - Handling conditions/check_tax.py @@ -7,6 +7,6 @@ # Check if the price is greater than 1.00 if price >= 1.00: - # Everything over $1.00 is charged 7% tax - tax = .07 - print('Tax rate is: ' + str(tax)) + # Everything over $1.00 is charged 7% tax + tax = .07 + print('Tax rate is: ' + str(tax)) diff --git a/python-for-beginners/08 - Handling conditions/code_challenge.py b/python-for-beginners/08 - Handling conditions/code_challenge.py index 4d1a5155..a030ffbf 100644 --- a/python-for-beginners/08 - Handling conditions/code_challenge.py +++ b/python-for-beginners/08 - Handling conditions/code_challenge.py @@ -5,8 +5,8 @@ price = input('how much did you pay? ') if price > 1.00: - tax = .07 - print('Tax rate is: ' + str(tax)) + tax = .07 + print('Tax rate is: ' + str(tax)) else - tax = 0 -print('Tax rate is: ' + str(tax)) \ No newline at end of file + tax = 0 +print('Tax rate is: ' + str(tax)) diff --git a/python-for-beginners/08 - Handling conditions/code_challenge_solution.py b/python-for-beginners/08 - Handling conditions/code_challenge_solution.py index 9238ddc2..e09fb00f 100644 --- a/python-for-beginners/08 - Handling conditions/code_challenge_solution.py +++ b/python-for-beginners/08 - Handling conditions/code_challenge_solution.py @@ -6,8 +6,8 @@ price = float(price) if price >= 1.00: - tax = .07 - print('Tax rate is: ' + str(tax)) + tax = .07 + print('Tax rate is: ' + str(tax)) else: tax = 0 - print('Tax rate is: ' + str(tax)) \ No newline at end of file + print('Tax rate is: ' + str(tax)) diff --git a/python-for-beginners/08 - Handling conditions/comparing_strings.py b/python-for-beginners/08 - Handling conditions/comparing_strings.py index 603be349..f330a0e9 100644 --- a/python-for-beginners/08 - Handling conditions/comparing_strings.py +++ b/python-for-beginners/08 - Handling conditions/comparing_strings.py @@ -1,7 +1,7 @@ country = input('Enter the name of your home country: ') if country == 'canada': - # string comparisons are case sensitive - # if you typed in CANADA or Canada it will not match - print('So you must like hockey!') + # string comparisons are case sensitive + # if you typed in CANADA or Canada it will not match + print('So you must like hockey!') else: - print('You are not from Canada') + print('You are not from Canada') diff --git a/python-for-beginners/09 - Handling multiple conditions/add_else_to_elif.py b/python-for-beginners/09 - Handling multiple conditions/add_else_to_elif.py index bcda842d..a58ee45f 100644 --- a/python-for-beginners/09 - Handling multiple conditions/add_else_to_elif.py +++ b/python-for-beginners/09 - Handling multiple conditions/add_else_to_elif.py @@ -2,11 +2,11 @@ tax = 0 if province == 'Alberta': - tax = 0.05 + tax = 0.05 elif province == 'Nunavut': - tax = 0.05 + tax = 0.05 elif province == 'Ontario': - tax = 0.13 + tax = 0.13 else: - tax = 0.15 -print(tax) \ No newline at end of file + tax = 0.15 +print(tax) diff --git a/python-for-beginners/09 - Handling multiple conditions/multiple_if_statements.py b/python-for-beginners/09 - Handling multiple conditions/multiple_if_statements.py index bd0983a0..d24d379d 100644 --- a/python-for-beginners/09 - Handling multiple conditions/multiple_if_statements.py +++ b/python-for-beginners/09 - Handling multiple conditions/multiple_if_statements.py @@ -1,11 +1,10 @@ - province = input("What province do you live in? ") tax = 0 if province == 'Alberta': - tax = 0.05 + tax = 0.05 if province == 'Nunavut': - tax = 0.05 + tax = 0.05 if province == 'Ontario': - tax = 0.13 + tax = 0.13 print(tax) diff --git a/python-for-beginners/09 - Handling multiple conditions/nested_if.py b/python-for-beginners/09 - Handling multiple conditions/nested_if.py index 571801b2..544e4a21 100644 --- a/python-for-beginners/09 - Handling multiple conditions/nested_if.py +++ b/python-for-beginners/09 - Handling multiple conditions/nested_if.py @@ -1,14 +1,13 @@ country = input("What country do you live in? ") if country.lower() == 'canada': - province = input("What province/state do you live in? ") - if province in('Alberta',\ - 'Nunavut','Yukon'): - tax = 0.05 - elif province == 'Ontario': - tax = 0.13 - else: - tax = 0.15 + province = input("What province/state do you live in? ") + if province in('Alberta','Nunavut','Yukon'): + tax = 0.05 + elif province == 'Ontario': + tax = 0.13 + else: + tax = 0.15 else: - tax = 0.0 + tax = 0.0 print(tax) diff --git a/python-for-beginners/09 - Handling multiple conditions/or_statements.py b/python-for-beginners/09 - Handling multiple conditions/or_statements.py index 5e80934d..822a2859 100644 --- a/python-for-beginners/09 - Handling multiple conditions/or_statements.py +++ b/python-for-beginners/09 - Handling multiple conditions/or_statements.py @@ -1,10 +1,10 @@ province = input("What province do you live in? ") tax = 0 if province == 'Alberta' \ - or province == 'Nunavut': - tax = 0.05 + or province == 'Nunavut': + tax = 0.05 elif province == 'Ontario': - tax = 0.13 + tax = 0.13 else: - tax = 0.15 + tax = 0.15 print(tax) diff --git a/python-for-beginners/09 - Handling multiple conditions/use_elif.py b/python-for-beginners/09 - Handling multiple conditions/use_elif.py index 61ed6a2f..f3205b00 100644 --- a/python-for-beginners/09 - Handling multiple conditions/use_elif.py +++ b/python-for-beginners/09 - Handling multiple conditions/use_elif.py @@ -1,9 +1,9 @@ province = input("What province do you live in? ") tax = 0 if province == 'Alberta': - tax = 0.05 + tax = 0.05 elif province == 'Nunavut': - tax = 0.05 + tax = 0.05 elif province == 'Ontario': - tax = 0.13 -print(tax) \ No newline at end of file + tax = 0.13 +print(tax) diff --git a/python-for-beginners/09 - Handling multiple conditions/use_in_statements.py b/python-for-beginners/09 - Handling multiple conditions/use_in_statements.py index fbac0037..8d95bdb4 100644 --- a/python-for-beginners/09 - Handling multiple conditions/use_in_statements.py +++ b/python-for-beginners/09 - Handling multiple conditions/use_in_statements.py @@ -3,9 +3,9 @@ # If multiple values cause the same output you can combine them by listing all # values you want to check for with the in operator if province in('Alberta','Nunavut','Yukon'): - tax = 0.05 + tax = 0.05 elif province == 'Ontario': - tax = 0.13 + tax = 0.13 else: - tax = 0.15 -print(tax) \ No newline at end of file + tax = 0.15 +print(tax) diff --git a/python-for-beginners/10 - Complex conditon checks/boolean_variables.py b/python-for-beginners/10 - Complex conditon checks/boolean_variables.py index 74949e43..993320c4 100644 --- a/python-for-beginners/10 - Complex conditon checks/boolean_variables.py +++ b/python-for-beginners/10 - Complex conditon checks/boolean_variables.py @@ -4,12 +4,12 @@ # Boolean variables allow you to remember a True/False value if gpa >= .85 and lowest_grade >= .70: - honour_roll = True + honour_roll = True else: - honour_roll = False + honour_roll = False # Somewhere later in your code if you need to check if students is # on honour roll, all I need to do is check the boolean variable # I set earlier in my code if honour_roll: - print('You made honour roll') + print('You made honour roll') diff --git a/python-for-beginners/10 - Complex conditon checks/code_challenge.py b/python-for-beginners/10 - Complex conditon checks/code_challenge.py index 3ffa8064..89881dec 100644 --- a/python-for-beginners/10 - Complex conditon checks/code_challenge.py +++ b/python-for-beginners/10 - Complex conditon checks/code_challenge.py @@ -5,13 +5,13 @@ # Ask the user for their last name # if first name is < 10 characters and last name is < 10 characters -# print first and last name on the jersey +# print first and last name on the jersey # if first name >= 10 characters long and last name is < 10 characters -# print first initial of first name and the entire last name +# print first initial of first name and the entire last name # if first name < 10 characters long and last name is >= 10 characters -# print entire first name and first initial of last name +# print entire first name and first initial of last name # if first name >= 10 characters long and last name is >= 10 characters -# print last name only +# print last name only # Test with the following values # first name: Susan last name: Ibach @@ -21,4 +21,4 @@ # first name: ReallyLongFirstName last name: Ibach # output: R. Ibach # first name: ReallyLongFirstName last name: ReallyLongLastName -# output: ReallyLongLastName \ No newline at end of file +# output: ReallyLongLastName diff --git a/python-for-beginners/10 - Complex conditon checks/code_challenge_solution.py b/python-for-beginners/10 - Complex conditon checks/code_challenge_solution.py index 9adc9700..9309fa91 100644 --- a/python-for-beginners/10 - Complex conditon checks/code_challenge_solution.py +++ b/python-for-beginners/10 - Complex conditon checks/code_challenge_solution.py @@ -6,13 +6,13 @@ last_name = input('Please enter your last name: ') # if first name is < 10 characters and last name is < 10 characters -# print first and last name on the jersey +# print first and last name on the jersey # if first name >= 10 characters long and last name is < 10 characters -# print first initial of first name and the entire last name +# print first initial of first name and the entire last name # if first name < 10 characters long and last name is >= 10 characters -# print entire first name and first initial of last name +# print entire first name and first initial of last name # if first name >= 10 characters long and last name is >= 10 characters -# print last name only +# print last name only # Check length of first name if len(first_name) >=10: @@ -34,4 +34,4 @@ elif long_last_name: print(first_name + ' ' + last_name[0:1] + '.') else: - print(first_name + ' ' + last_name) \ No newline at end of file + print(first_name + ' ' + last_name) diff --git a/python-for-beginners/10 - Complex conditon checks/using_and.py b/python-for-beginners/10 - Complex conditon checks/using_and.py index 0a1204af..83fe9636 100644 --- a/python-for-beginners/10 - Complex conditon checks/using_and.py +++ b/python-for-beginners/10 - Complex conditon checks/using_and.py @@ -5,5 +5,5 @@ lowest_grade = float(lowest_grade) if gpa >= .85 and lowest_grade >= .70: - print('You made the honour roll') + print('You made the honour roll') diff --git a/python-for-beginners/12 - Loops/for.py b/python-for-beginners/12 - Loops/for.py index 90bf46a5..b33718d0 100644 --- a/python-for-beginners/12 - Loops/for.py +++ b/python-for-beginners/12 - Loops/for.py @@ -1,2 +1,2 @@ for name in ['Christopher', 'Susan']: - print(name) + print(name) diff --git a/python-for-beginners/12 - Loops/number.py b/python-for-beginners/12 - Loops/number.py index b9d4caad..49a66f1e 100644 --- a/python-for-beginners/12 - Loops/number.py +++ b/python-for-beginners/12 - Loops/number.py @@ -3,4 +3,4 @@ # Second indicates the number of numbers to create # range(0, 2) creates [0, 1] for index in range(0, 2): - print(index) + print(index) diff --git a/python-for-beginners/12 - Loops/while.py b/python-for-beginners/12 - Loops/while.py index f2ab2abf..324defc2 100644 --- a/python-for-beginners/12 - Loops/while.py +++ b/python-for-beginners/12 - Loops/while.py @@ -1,6 +1,6 @@ names = ['Christopher', 'Susan'] index = 0 while index < len(names): - print(names[index]) - # Change the condition!! - index = index + 1 + print(names[index]) + # Change the condition!! + index = index + 1 diff --git a/python-for-beginners/13 - Functions/code_challenge_solution.py b/python-for-beginners/13 - Functions/code_challenge_solution.py index 71a3ace2..fb695eb5 100644 --- a/python-for-beginners/13 - Functions/code_challenge_solution.py +++ b/python-for-beginners/13 - Functions/code_challenge_solution.py @@ -6,7 +6,6 @@ # the function should return the result of the two numbers added or subtracted # based on the value passed in for the operator # - def calculator(first_number, second_number, operation): if operation.upper() == 'ADD': return(float(first_number) + float(second_number)) @@ -23,4 +22,4 @@ def calculator(first_number, second_number, operation): print('Subtracting 6 - 4 = ' + str(calculator(6,4,'subtract'))) # Test your function with the values 6,4, divide # Should return some sort of error message -print('Dividing 6 / 4 = ' + str(calculator(6,4,'divide'))) \ No newline at end of file +print('Dividing 6 / 4 = ' + str(calculator(6,4,'divide'))) diff --git a/python-for-beginners/13 - Functions/get_initails_function.py b/python-for-beginners/13 - Functions/get_initails_function.py index 46a5b0c6..d9b8577a 100644 --- a/python-for-beginners/13 - Functions/get_initails_function.py +++ b/python-for-beginners/13 - Functions/get_initails_function.py @@ -22,4 +22,4 @@ def get_initial(name): last_name_initial = get_initial(last_name) print('Your initials are: ' + first_name_initial \ - + middle_name_initial + last_name_initial) \ No newline at end of file + + middle_name_initial + last_name_initial) diff --git a/python-for-beginners/13 - Functions/get_initials.py b/python-for-beginners/13 - Functions/get_initials.py index a5b1ee4a..eb905c0a 100644 --- a/python-for-beginners/13 - Functions/get_initials.py +++ b/python-for-beginners/13 - Functions/get_initials.py @@ -9,5 +9,5 @@ last_name_initial = last_name[0:1] print('Your initials are: ' + first_name_initial \ - + middle_name_initial + last_name_initial) + + middle_name_initial + last_name_initial) diff --git a/python-for-beginners/13 - Functions/getting_clever_with_functions_harder_to_read.py b/python-for-beginners/13 - Functions/getting_clever_with_functions_harder_to_read.py index 5221dce8..4d605781 100644 --- a/python-for-beginners/13 - Functions/getting_clever_with_functions_harder_to_read.py +++ b/python-for-beginners/13 - Functions/getting_clever_with_functions_harder_to_read.py @@ -17,4 +17,4 @@ def get_initial(name): print('Your initials are: ' \ + get_initial(first_name) \ + get_initial(middle_name) \ - + get_initial(last_name)) \ No newline at end of file + + get_initial(last_name)) diff --git a/python-for-beginners/13 - Functions/print_time_function_different_messages.py b/python-for-beginners/13 - Functions/print_time_function_different_messages.py index 68dfe271..fb20bb8f 100644 --- a/python-for-beginners/13 - Functions/print_time_function_different_messages.py +++ b/python-for-beginners/13 - Functions/print_time_function_different_messages.py @@ -8,7 +8,7 @@ print() for x in range(0,10): - print(x) + print(x) print('loop completed') print(datetime.now()) print() diff --git a/python-for-beginners/13 - Functions/print_time_with_message_parameter.py b/python-for-beginners/13 - Functions/print_time_with_message_parameter.py index 5670fc53..4c578301 100644 --- a/python-for-beginners/13 - Functions/print_time_with_message_parameter.py +++ b/python-for-beginners/13 - Functions/print_time_with_message_parameter.py @@ -14,7 +14,7 @@ def print_time(task_name): print_time('first name assigned') for x in range(0,10): - print(x) + print(x) # Call print_time() function to display message and current time # pass in name of task completed print_time('loop completed') diff --git a/python-for-beginners/14 - Function parameters/get_initials_named_parameters.py b/python-for-beginners/14 - Function parameters/get_initials_named_parameters.py index 3b7dac60..a0727035 100644 --- a/python-for-beginners/14 - Function parameters/get_initials_named_parameters.py +++ b/python-for-beginners/14 - Function parameters/get_initials_named_parameters.py @@ -16,7 +16,9 @@ def get_initial(name, force_uppercase): # Call get_initial to retrieve first letter of name # When you use named notation, you can specify parameters in any order -first_name_initial = get_initial(force_uppercase=True, \ - name=first_name) +first_name_initial = get_initial( + force_uppercase=True, + name=first_name +) -print('Your initial is: ' + first_name_initial) \ No newline at end of file +print('Your initial is: ' + first_name_initial) diff --git a/python-for-beginners/14 - Function parameters/named_parameters_make_code_readable.py b/python-for-beginners/14 - Function parameters/named_parameters_make_code_readable.py index 3d1e8a0d..5fdf468b 100644 --- a/python-for-beginners/14 - Function parameters/named_parameters_make_code_readable.py +++ b/python-for-beginners/14 - Function parameters/named_parameters_make_code_readable.py @@ -26,8 +26,10 @@ def error_logger(error_code, error_severity, log_to_db, error_message, source_mo if first_number > second_number: # This function call by itself is easier to understand because I can # see how the values I pass in map to the function parameters - error_logger(error_code=45, - error_severity=1, - log_to_db=True, - error_message='Second number greater than first', - source_module='adding_method') + error_logger( + error_code=45, + error_severity=1, + log_to_db=True, + error_message='Second number greater than first', + source_module='adding_method' + ) diff --git a/python-for-beginners/16 - Calling APIs/call_api.py b/python-for-beginners/16 - Calling APIs/call_api.py index 0bd9ab74..f2343acb 100644 --- a/python-for-beginners/16 - Calling APIs/call_api.py +++ b/python-for-beginners/16 - Calling APIs/call_api.py @@ -22,8 +22,10 @@ # According to the documentation for the analyze image function # There are three optional parameters: language, details & visualFeatures -parameters = {'visualFeatures':'Description,Color', - 'language':'en'} +parameters = { + 'visualFeatures':'Description,Color', + 'language':'en' +} # Open the image file to get a file object containing the image to analyze image_path = "./TestImages/PolarBear.jpg" @@ -32,8 +34,10 @@ # According to the documentation for the analyze image function # we need to specify the subscription key and the content type # in the HTTP header. Content-Type is application/octet-stream when you pass in a image directly -headers = {'Content-Type': 'application/octet-stream', - 'Ocp-Apim-Subscription-Key': SUBSCRIPTION_KEY} +headers = { + 'Content-Type':'application/octet-stream', + 'Ocp-Apim-Subscription-Key':SUBSCRIPTION_KEY +} # According to the documentation for the analyze image function # we use HTTP POST to call this function diff --git a/python-for-beginners/17 - JSON/read_json.py b/python-for-beginners/17 - JSON/read_json.py index 4346ec41..6a9ef5df 100644 --- a/python-for-beginners/17 - JSON/read_json.py +++ b/python-for-beginners/17 - JSON/read_json.py @@ -16,8 +16,10 @@ # According to the documentation for the analyze image function # There are three optional parameters: language, details & visualFeatures -parameters = {'visualFeatures':'Description,Color', - 'language':'en'} +parameters = { + 'visualFeatures':'Description,Color', + 'language':'en' +} # We need the key to access our Computer Vision Service subscription_key = "cf229a23c3054905b5a8ad512edfa9dd" @@ -29,8 +31,10 @@ # According to the documentation for the analyze image function # we need to specify the subscription key and the content type # in the HTTP header. Content-Type is application/octet-stream when you pass in a image directly -headers = {'Content-Type': 'application/octet-stream', - 'Ocp-Apim-Subscription-Key': subscription_key} +headers = { + 'Content-Type':'application/octet-stream', + 'Ocp-Apim-Subscription-Key':subscription_key +} # According to the documentation for the analyze image function # we use HTTP POST to call this function @@ -57,4 +61,3 @@ print('caption text') print(results['description']['captions'][0]['text']) - diff --git a/python-for-beginners/17 - JSON/read_key_pair.py b/python-for-beginners/17 - JSON/read_key_pair.py index 367b5f54..0ac22b17 100644 --- a/python-for-beginners/17 - JSON/read_key_pair.py +++ b/python-for-beginners/17 - JSON/read_key_pair.py @@ -16,8 +16,10 @@ # According to the documentation for the analyze image function # There are three optional parameters: language, details & visualFeatures -parameters = {'visualFeatures':'Description,Color', - 'language':'en'} +parameters = { + 'visualFeatures':'Description,Color', + 'language':'en' +} # We need the key to access our Computer Vision Service subscription_key = "xxxxxxxxxxxxxxxxxxxx" @@ -29,8 +31,10 @@ # According to the documentation for the analyze image function # we need to specify the subscription key and the content type # in the HTTP header. Content-Type is application/octet-stream when you pass in a image directly -headers = {'Content-Type': 'application/octet-stream', - 'Ocp-Apim-Subscription-Key': subscription_key} +headers = { + 'Content-Type': 'application/octet-stream', + 'Ocp-Apim-Subscription-Key': subscription_key +} # According to the documentation for the analyze image function # we use HTTP POST to call this function @@ -46,4 +50,4 @@ # print the value for requestId from the JSON output print() print('requestId') -print (results['requestId']) \ No newline at end of file +print (results['requestId']) diff --git a/python-for-beginners/17 - JSON/read_key_pair_list.py b/python-for-beginners/17 - JSON/read_key_pair_list.py index 333a153b..adc2a6c5 100644 --- a/python-for-beginners/17 - JSON/read_key_pair_list.py +++ b/python-for-beginners/17 - JSON/read_key_pair_list.py @@ -16,8 +16,10 @@ # According to the documentation for the analyze image function # There are three optional parameters: language, details & visualFeatures -parameters = {'visualFeatures':'Description,Color', - 'language':'en'} +parameters = { + 'visualFeatures':'Description,Color', + 'language':'en' +} # We need the key to access our Computer Vision Service subscription_key = "xxxxxxxxxxxxxxxxxxxxxxx" @@ -29,8 +31,10 @@ # According to the documentation for the analyze image function # we need to specify the subscription key and the content type # in the HTTP header. Content-Type is application/octet-stream when you pass in a image directly -headers = {'Content-Type': 'application/octet-stream', - 'Ocp-Apim-Subscription-Key': subscription_key} +headers = { + 'Content-Type':'application/octet-stream', + 'Ocp-Apim-Subscription-Key':subscription_key +} # According to the documentation for the analyze image function # we use HTTP POST to call this function diff --git a/python-for-beginners/17 - JSON/read_subkey.py b/python-for-beginners/17 - JSON/read_subkey.py index cfafed25..8e072056 100644 --- a/python-for-beginners/17 - JSON/read_subkey.py +++ b/python-for-beginners/17 - JSON/read_subkey.py @@ -16,8 +16,10 @@ # According to the documentation for the analyze image function # There are three optional parameters: language, details & visualFeatures -parameters = {'visualFeatures':'Description,Color', - 'language':'en'} +parameters = { + 'visualFeatures':'Description,Color', + 'language':'en' +} # We need the key to access our Computer Vision Service subscription_key = "xxxxxxxxxxxxxxxxxxxxxxx" @@ -29,8 +31,10 @@ # According to the documentation for the analyze image function # we need to specify the subscription key and the content type # in the HTTP header. Content-Type is application/octet-stream when you pass in a image directly -headers = {'Content-Type': 'application/octet-stream', - 'Ocp-Apim-Subscription-Key': subscription_key} +headers = { + 'Content-Type':'application/octet-stream', + 'Ocp-Apim-Subscription-Key':subscription_key +} # According to the documentation for the analyze image function # we use HTTP POST to call this function @@ -46,4 +50,4 @@ # Print the value for dominantColorBackground from the color keys print() print('dominantColorBackground') -print(results['color']['dominantColorBackground']) \ No newline at end of file +print(results['color']['dominantColorBackground'])