Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 : Write a function named sort _ as _ str that takes three integers and return a string containing the numbers in sorted

Problem 1: Write a function named sort_as_str that takes three integers and return a string containing the numbers in sorted order.
For example: sort_as_str 546 would return "4:5:6"
Problem 2: Write the following functions:
abs a - return the absolute value of a
inc a - returns a +1
dec a - return a 1
double a - returns 2* a
tribple a return a *3
half a return a /2
Print the result for the expression below:
-2|> double |> triple |> inc |> half |> abs |> dec |> dec
Problem 3: Write a recursive function named divide that takes two integers that returns the result of the number by the second number. You can assume that the numbers are positive. The function uses the -(subtraction) operator to recursively compute result. The result is the number of time it takes to decrement the first number by the second number until the first number is less than the second number.
divide 52 would return 2
divide 123 would return 4

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions