Explore BrainMass
Share

# Intro CS using Python

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Def y():
""" y does this function exist?
** just to illustrate a 0-input function...
"""
return 1

def w(x):
""" w computes thrice its input plus one
** plus it offers a chance to use the word "thrice"
input x: any number (int or float)
"""
return 3*(x+1)

def t(x):
""" t computes thrice its input plus one
** and shows how python is more precise than English
input x: any number (int or float)
"""
return 3*x + 1

def r(x,y):
""" r shows some less-common arithmetic operators
input x: any number (int or float)
input y: any number (int or float, more likely int)
"""
return ( x**2 % y ) + 2

def f(a,b):
""" f demonstrates the use of conditionals (if/elif/else)
** and that input parameters' names don't matter
input a: any number (int or float)
input b: any number (int or float)
"""
if a < b:
return (b-1) * (b-2)
else:
return (a+42) * (b+42)

PROBLEM

What is the return statement that satisfies these input/output constraints? Note: This function takes two inputs. You will need to pass them as (input1, input2)

an input of (3,4) returns 5

an input of (24,7) returns 25

an input of (42,1) returns 42.01190307520001

Use words to describe the solution steps, not just symbols.