Add Area

From CompSciWiki
Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

Write a function that has two parameters. It will return the conbination of the two parameters.

Example:
combineNumber(204, 8998810)

Output:
2048998810

 

Introducing Functions

Solution

The skeleton structure will be like this:

 def combineNumber(areaCode, phoneNumber):

  return result
def main():

main() 

We can start to write the combineNumber function

 def conbineNumber(areaCode, phoneNumber):
  areaCode = areaCode * 10000000
  result = areaCode + phoneNumber
  return result 

We can finish the main function

 def main():
  temp = combineNumber(204, 8998810)
  print temp
main() 

Code

Solution Code

Back to the Program-A-Day homepage