Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . greatestOfFour ( w , x , y , z ) - Function returns the greatest of four numbers w , x , y

1. greatestOfFour (w, x, y, z)- Function returns the greatest of four numbers w, x, y, and z, and return it. Sample code:
# Function Name: greatestOfFour
# Desc: Finds greatest of 4 numbers
# Parameters: num1- int, num2- int, num3- int, num4- int
# Return: int
def greatestOfFour(num1, num2, num3, num4): if num1>num2 and num1>num3 and num1>num4:
return num1
elif num2>num3 and num2>num4:
return num2 elif num3>num4: return num3
else: return num4 # Read Input
print("Enter four numbers to check the greatest: ") num1= input("1st num: ")
num2= input("2nd num: ")
num3= input("3rd num: ")
num4= input("4th num: ")
# Call function for Process and Output
print("Greatest of 4 numbers: ")
print(greatestOfFour(int(num1), int(num2), int(num3), int(num4)))
Output:
2. reverseSentence(sentence)- Function that returns the reverse of a given sentence (words) entered by user.
3. listOdd(n1, n2) Function to return list of all the odd numbers between two numbers.
4. calculateTotalSalary(month_sal, no_of_years)- Function returns the computed total salary based on monthly salary and number of years. If the number of years is greater than 4 years, an increment of 3%
is added to the total salary from 5th year.
5. listMax(numList) Function returns the maximum from a list of numbers.
6. profit_or_loss(cost_price,selling_price)- Function returns the calculated actual profit or loss based on
cost price and selling price using the formula, Profit =(Selling Price - Cost Price) and Loss =(Cost Price -
Selling Price).
7. printEveIndexChar(str)- Function that returns only those characters which are present at an even index
number in a given String.
8. rental_car_cost(rate_per_day, no_of_days)- Function that returns the calculated cost of renting the car
based on the rental rate per day and number of days the car is rented. If you rent the car for 7 or more days, you get $40 off your total cost. Alternatively, if you rent the car for 3 or more days, you get $20 off your total. You cannot get both of the above discounts at the same time.
9. average(list)- Function to find the average of given list of numbers.
10. square_of_numbers(num1, num2)-function to create and returns a list where the values are square of
numbers between 1 and 30(both included).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

What is a bibliography?

Answered: 1 week ago