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) 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) 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 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__": 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__": 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__": 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 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 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 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: 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: 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) 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)