Skip to content

Instantly share code, notes, and snippets.

@lucpet
Last active December 21, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucpet/6290277 to your computer and use it in GitHub Desktop.
Save lucpet/6290277 to your computer and use it in GitHub Desktop.
# 1. Write a function that takes two number parameters and
# returns their product
def mult_me(x, y):
z = x * y
return z
mult_me(123, -2)
#-----------------------------------------------------------
# 2. Write a function that takes two string parameters and
# returns a string that is a concatenation of the second
# parameter to the first
def concat(string1, string2):
blah = string1 + string2
return blah
concat("Bite ", "me")
#-----------------------------------------------------------
# 3. Write a function that takes two number parameters and
# returns a float that is the result of dividing the first
# parameter by the second
def floating(c, v):
b = c / v
return b
floating(6.5, 2)
#-----------------------------------------------------------
# 4. Write a function that takes two number parameters and
# returns their sum.
def sumin(num1, num2):
summer = num1 + num2
return summer
sumin(50,35)
#-----------------------------------------------------------
# 5. Write a function that takes two number parameters and
# returns the result of subtracting the second parameter
# from the first.
def oh_cookie(num3, num4):
milk = num3 - num4
return milk
oh_cookie(100, 76)
#-----------------------------------------------------------
# 6. Write a function that takes two number parameters and
# returns their average. Hint: You can call some of the
# previous functions for this.
def awb(num5, num6):
pom = (num5 + num6) / 2
return pom
awb(120, 200)
#-----------------------------------------------------------
# 7. Write a function that takes a float and returns the
# whole number part of the float (get rid of any decimal
# places.
def floater(num7):
omg = num7 // 1
return omg
floater(99.7)
#-----------------------------------------------------------
# 8. Write a function that takes two numbers: a number to
# round, and a number of decimal places to round the first
# number to.
def around(num8,num9):
struth = round(num8,num9)
return struth
around(99.9999,2)
#-----------------------------------------------------------
@kylelk
Copy link

kylelk commented Aug 21, 2013

Neat program!

@lucpet
Copy link
Author

lucpet commented Aug 23, 2013

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment