From 532c4174cd726fd96f45bc38455c5dddabd94458 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:56:48 +0530 Subject: [PATCH 01/13] exercise solved --- employee-salary-calculation/01_employee_salary_calculation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/employee-salary-calculation/01_employee_salary_calculation.py b/employee-salary-calculation/01_employee_salary_calculation.py index 768e23c..cde0b10 100644 --- a/employee-salary-calculation/01_employee_salary_calculation.py +++ b/employee-salary-calculation/01_employee_salary_calculation.py @@ -13,13 +13,13 @@ print("Enter the gross income") # raw_input gets the input from the keyboard through user -gross_income = float(raw_input()) +gross_income = float(input()) # Enter the federal tax print("Enter the federal_tax") # Getting the federal tax from the user -fedral_tax = float(raw_input()) +fedral_tax = float(input()) # Taxable income will be reduced from gross income.This is the fixed dedutable income taxable_deduction = 12000 From 361ac046eddb8f44102780102f19de17ccde546d Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:57:07 +0530 Subject: [PATCH 02/13] exercise solved --- employee-salary-calculation/02_employee_salary_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/employee-salary-calculation/02_employee_salary_calculation.py b/employee-salary-calculation/02_employee_salary_calculation.py index f8bb7d1..70144c1 100644 --- a/employee-salary-calculation/02_employee_salary_calculation.py +++ b/employee-salary-calculation/02_employee_salary_calculation.py @@ -19,7 +19,7 @@ # Enter the gross income print("Enter the gross income") -gross_income = float(raw_input()) +gross_income = float(input()) # Taxable income will be reduced from gross income taxable_deduction = 12000 From 4e789f9e6a74bd386bda811a0b4eb073ac59db77 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:57:23 +0530 Subject: [PATCH 03/13] exercise solved --- employee-salary-calculation/03_employee_salary_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/employee-salary-calculation/03_employee_salary_calculation.py b/employee-salary-calculation/03_employee_salary_calculation.py index 8d279ff..62a076b 100644 --- a/employee-salary-calculation/03_employee_salary_calculation.py +++ b/employee-salary-calculation/03_employee_salary_calculation.py @@ -93,7 +93,7 @@ def employee_take_home_salary(federal_tax): if __name__ == "__main__": # Enter the gross income print("Enter the gross income") - gross_income = float(raw_input()) + gross_income = float(input()) taxable_deduction = 12000 # Taxable income From 166c16953f7843d83729b5dafac894b808562aef Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:57:36 +0530 Subject: [PATCH 04/13] exercise solved --- .../04_employee_salary_calculation.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/employee-salary-calculation/04_employee_salary_calculation.py b/employee-salary-calculation/04_employee_salary_calculation.py index b589369..69e7fcc 100644 --- a/employee-salary-calculation/04_employee_salary_calculation.py +++ b/employee-salary-calculation/04_employee_salary_calculation.py @@ -69,8 +69,8 @@ def employee_federal_tax(employee_name,taxable_income): federal_tax =0 print("The employee no need to pay the federal tax") - print("%s federal tax is %s" %(employee_name,federal_tax)) - + # print("federal tax is %s") %employee_name,federal_tax + print("The federal tax for %s is %s"% (employee_name,federal_tax)) return federal_tax def employee_take_homes_salary(employee_name,employee_gross_income,federal_tax): @@ -83,7 +83,7 @@ def employee_take_homes_salary(employee_name,employee_gross_income,federal_tax): # 1.45% of gross income is medicare tax medicare_tax = float(employee_gross_income) *(1.45/100) - print 'The medicare tax for %s is %s'%(employee_name,medicare_tax) + print("The medicare tax for %s is %s"%(employee_name,medicare_tax)) # Taxable due taxable_due = federal_tax + social_security + medicare_tax @@ -116,8 +116,9 @@ def calculate_take_home_salary(all_lines): def read_employee_salary_csv_file(): "This functions reads the CSV file" - # To read the CSV file we have to join the path where it's located - filename = os.path.abspath(os.path.join('..','training/data',"employee_payroll.csv")) + # To read the CSV file we have to join the path where it's located + path = "C:\\Users\\Rahul Bhave Qxf2\\code\\rahul-qxf2" + filename = os.path.abspath(os.path.join(path,"tsqa-basic\\data","employee_payroll.csv")) # To open the text file and assign to object fp with open(filename,"r") as fp: From d20cd22a8fcd9485e6e3ad05ed7b33d457e5dae8 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:57:52 +0530 Subject: [PATCH 05/13] exercise solved --- employee-salary-calculation/05_employee_salary_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/employee-salary-calculation/05_employee_salary_calculation.py b/employee-salary-calculation/05_employee_salary_calculation.py index d683b16..27710be 100644 --- a/employee-salary-calculation/05_employee_salary_calculation.py +++ b/employee-salary-calculation/05_employee_salary_calculation.py @@ -98,7 +98,7 @@ def employee_take_home_salary(federal_tax): print("Enter the employee gross income") # Get the input from the user and check it's of correct type try: - gross_income = float(raw_input()) + gross_income = float(input()) break # If user inputs wrong type then the except will run except ValueError: From c460bc59b66ee1e3b2a9256f14783443f0bc598d Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:58:25 +0530 Subject: [PATCH 06/13] exercise solved --- .../07_employee_salary_calculation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/employee-salary-calculation/07_employee_salary_calculation.py b/employee-salary-calculation/07_employee_salary_calculation.py index 2f9f80d..61432d0 100644 --- a/employee-salary-calculation/07_employee_salary_calculation.py +++ b/employee-salary-calculation/07_employee_salary_calculation.py @@ -117,8 +117,9 @@ def calculate_take_home_salary(csv_file): def read_employee_salary_csv_file(): "This functions reads the CSV file" # To read the CSV file we have to join the path where it's located - filename = os.path.abspath(os.path.join('..','training/data',"employee_payroll.csv")) - + path = "C:\\Users\\Rahul Bhave Qxf2\\code\\rahul-qxf2" + filename = os.path.abspath(os.path.join(path,"tsqa-basic\\data","employee_payroll.csv")) + # To open the text file and assign to object fp with open(filename,"r") as fp: csv_file = csv.reader(fp) From d0874b0de8284ec2c16cd6292e4cac4d84d497a0 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 11:58:56 +0530 Subject: [PATCH 07/13] exercise solved --- employee-salary-calculation/shopping_cart_module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/employee-salary-calculation/shopping_cart_module.py b/employee-salary-calculation/shopping_cart_module.py index f165d80..99eaebc 100644 --- a/employee-salary-calculation/shopping_cart_module.py +++ b/employee-salary-calculation/shopping_cart_module.py @@ -5,10 +5,10 @@ def __init__(self): def add_item(self,item): "Adding and updating the items into the cart" - if not self.shopping_cart.has_key(item.item_name): + if item.item_name not in self.shopping_cart.keys(): self.shopping_cart.update({item.item_name:item.item_quantity}) else: - for key,value in self.shopping_cart.iteritems(): + for key,value in self.shopping_cart.items(): if key == item.item_name and value == item.item_quantity: print ("The item and quantity you are trying to add are in the shopping cart already,no need to add it") @@ -22,7 +22,7 @@ def remove_item(self,item): "Removing an item from the list" if not self.shopping_cart: print("There is no shopping cart and you cant delete it") - for key,values in self.shopping_cart.iteritems(): + for key,values in self.shopping_cart.items(): if key ==item.item_name and values == item.item_quantity: item_to_remove = key self.shopping_cart.pop(item_to_remove) From 4c3753c49c8d48f514561352ac87b7367938f03a Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 12:00:31 +0530 Subject: [PATCH 08/13] exercise solved --- BMI-calculator/01_BMI_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BMI-calculator/01_BMI_calculator.py b/BMI-calculator/01_BMI_calculator.py index 5465983..4761596 100644 --- a/BMI-calculator/01_BMI_calculator.py +++ b/BMI-calculator/01_BMI_calculator.py @@ -19,11 +19,11 @@ print("Enter the weight of the user in Kg's") # Get the weight of the user through keyboard -weight_of_the_user = input() +weight_of_the_user = float(input()) # Get the height of the user through keyboard print("Enter the height of the user in meters") -height_of_the_user = input() +height_of_the_user = float(input()) # Calculate the BMI of the user according to height and weight bmi_of_the_user = weight_of_the_user/(height_of_the_user * height_of_the_user) From 79c32bbfa142b955162bfda411c59347feaa1c23 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 12:00:54 +0530 Subject: [PATCH 09/13] exercise solved --- BMI-calculator/02_BMI_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BMI-calculator/02_BMI_calculator.py b/BMI-calculator/02_BMI_calculator.py index 22ac1d4..27c424e 100644 --- a/BMI-calculator/02_BMI_calculator.py +++ b/BMI-calculator/02_BMI_calculator.py @@ -24,11 +24,11 @@ print("Enter the weight of the user in Kg's") # Get the weight of the user through keyboard -weight_of_the_user = input() +weight_of_the_user = float(input()) # Get the height of the user through keyboard print("Enter the height of the user in meters") -height_of_the_user = input() +height_of_the_user = float(input()) # Calculate the BMI of the user according to height and weight bmi = weight_of_the_user/(height_of_the_user * height_of_the_user) From 79b3faef4568fed037c3e1384800b172034fd826 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 12:01:11 +0530 Subject: [PATCH 10/13] exercise solved --- BMI-calculator/03_BMI_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BMI-calculator/03_BMI_calculator.py b/BMI-calculator/03_BMI_calculator.py index 04fa824..69452b2 100644 --- a/BMI-calculator/03_BMI_calculator.py +++ b/BMI-calculator/03_BMI_calculator.py @@ -31,11 +31,11 @@ def get_input_to_calcluate_bmi(): "This function gets the input from the user" print("Enter the weight of the user in Kgs") # Get the weight of the user through keyboard - weight_of_the_user = input() + weight_of_the_user = float(input()) # Get the height of the user through keyboard print("Enter the height of the user in meters") - height_of_the_user = input() + height_of_the_user = float(input()) return weight_of_the_user,height_of_the_user From beb956ad25614dfc2180ba6bf4d0a4a07d583734 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 12:02:41 +0530 Subject: [PATCH 11/13] exercise solved --- BMI-calculator/04_BMI_calculator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BMI-calculator/04_BMI_calculator.py b/BMI-calculator/04_BMI_calculator.py index 7a9b8ea..8a5b836 100644 --- a/BMI-calculator/04_BMI_calculator.py +++ b/BMI-calculator/04_BMI_calculator.py @@ -34,11 +34,11 @@ def get_input_to_calcluate_bmi(): "This function gets the input from the user" print("Enter the weight of the user in Kg's") # Get the weight of the user through keyboard - weight_of_the_user = input() + weight_of_the_user = float(input()) # Get the height of the user through keyboard print("Enter the height of the user in meters") - height_of_the_user = input() + height_of_the_user = float(input()) return weight_of_the_user,height_of_the_user @@ -83,7 +83,7 @@ def compare_user_bmi_with_player_csv(bmi_value): print("Your BMI is not matching with any of the players dataset which is used here") else: print("Your BMI is matching with") - print matched_player + print (matched_player) # Program starts here if __name__ == "__main__": From 333fcc8d1f4dc9419735e175410b927a1eb8dbdc Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 12:02:56 +0530 Subject: [PATCH 12/13] exercise solved --- BMI-calculator/05_BMI_calculator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BMI-calculator/05_BMI_calculator.py b/BMI-calculator/05_BMI_calculator.py index f4c7df9..3bfef25 100644 --- a/BMI-calculator/05_BMI_calculator.py +++ b/BMI-calculator/05_BMI_calculator.py @@ -40,7 +40,7 @@ def get_input_to_calcluate_bmi(): print("Enter the weight of the user in Kg's") # Get the input from the user and check it's of correct type try: - weight_of_the_user = float(raw_input()) + weight_of_the_user = float(input()) # isintance will check the type of the input and returns true/false if isinstance(weight_of_the_user,float): break @@ -52,7 +52,7 @@ def get_input_to_calcluate_bmi(): while True: print("Enter the height of the user in Kg's") try: - height_of_the_user = float(raw_input()) + height_of_the_user = float(input()) if isinstance(height_of_the_user,float): break except ValueError: @@ -100,7 +100,7 @@ def compare_user_bmi_with_player_csv(bmi_value): print("Your BMI is not matching with any of the players dataset which is used here") else: print("Your BMI is matching with") - print matched_player + print (matched_player) # Program starts here if __name__ == "__main__": From bca65e1dcffa7daaeb0092d37d7759b413a79ade Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Mon, 23 Sep 2019 12:03:42 +0530 Subject: [PATCH 13/13] exercise solved --- BMI-calculator/06_BMI_Calculator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BMI-calculator/06_BMI_Calculator.py b/BMI-calculator/06_BMI_Calculator.py index 92e001d..d1918df 100644 --- a/BMI-calculator/06_BMI_Calculator.py +++ b/BMI-calculator/06_BMI_Calculator.py @@ -41,7 +41,7 @@ def get_input_to_calcluate_bmi(): print("Enter the weight of the user in Kg's") # Get the input from the user and check it's of correct type try: - weight_of_the_user = float(raw_input()) + weight_of_the_user = float(input()) # isintance will check the type of the input and returns true/false if isinstance(weight_of_the_user,float): break @@ -53,7 +53,7 @@ def get_input_to_calcluate_bmi(): while True: print("Enter the height of the user in Kg's") try: - height_of_the_user = float(raw_input()) + height_of_the_user = float(input()) if isinstance(height_of_the_user,float): break except ValueError: @@ -87,7 +87,7 @@ def compare_user_bmi_with_player_csv(bmi_of_the_user): with open(filename,"r") as fp: csv_file = csv.reader(fp) next(csv_file) - for i, row in enumerate(csv_file): + for row, row in enumerate(csv_file): bmi_value_in_row = row[3] player_name = row[0] if float(bmi_value_in_row) == bmi_of_the_user: @@ -96,7 +96,7 @@ def compare_user_bmi_with_player_csv(bmi_of_the_user): print("No matching data") else: print("Your BMI is matching with") - print matched_player + print (matched_player) # Program starts here if __name__ == "__main__":