Answer to Question #291223 in Python for H A

Question #291223

Function:


question 1:  convert inche-mm
question 2:  convert Celsius-Fahrenheit
question 3:  return max of 3 nums
question 4:  input and combine title+first+last
question 5:  car_rental (dayrate, #days) get discount with >5 dayes , >10 days

I want very simple code for them


1
Expert's answer
2022-01-27T07:46:59-0500
def inch_to_mm(inch):
	'''
	convert inche-mm
	'''
	return inch * 25.4


def cels_to_fahr(cels):
	'''
	convert Celsius-Fahrenheit
	'''
	return (cels*9/5) + 32


def max_of_nums(num1, num2, num3):
	'''
	return max of 3 nums
	'''
	if num1 > num2:
		if num1 > num3:
			return num1
		else:
			return num3
	elif num2 > num3:
		return num2
	else:
		return num3


def input_and_combain():
	'''
	input and combine title+first+last
	'''
	title = input("title: ")
	first = input("first: ")
	last = input("last: ")
	return title + " " + first + " " + last


def car_rental(dayrate, days):
	'''
	car_rental (dayrate, #days) get discount
	with >5 days - 5% , >10 days - 10%
	'''
	rent = dayrate * days
	if days >= 10:
		rent -= 0.1*rent
	elif days >= 5:
		rent -= 0.05*rent
	return rent


#Testing functions
print(max_of_nums(2,1,2))
print(inch_to_mm(10))
print(cels_to_fahr(0))
print(input_and_combain())
print(car_rental(15,20))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS