Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BMI-calculator/01_BMI_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions BMI-calculator/02_BMI_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions BMI-calculator/03_BMI_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions BMI-calculator/04_BMI_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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__":
Expand Down
6 changes: 3 additions & 3 deletions BMI-calculator/05_BMI_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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__":
Expand Down
8 changes: 4 additions & 4 deletions BMI-calculator/06_BMI_Calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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__":
Expand Down
4 changes: 2 additions & 2 deletions employee-salary-calculation/01_employee_salary_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions employee-salary-calculation/04_employee_salary_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions employee-salary-calculation/07_employee_salary_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions employee-salary-calculation/shopping_cart_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)
Expand Down