CSC111 Homework 6 2015

From dftwiki3
Revision as of 17:25, 1 March 2015 by Thiebaut (talk | contribs)
Jump to: navigation, search

--D. Thiebaut (talk) 16:18, 1 March 2015 (EST)


<showafterdate after="20150305 16:00" before="20150601 00:00">

Preparation


  • Create a program called testHw6.py with the code available on this page. Save it in the same place where you will store your hw6.py program.
  • Create a second program, called hw6.py. This program will contain all the functions that you are asked to write for this assignment. Add the code below to your hw6.py code:


# hw6.py
# yourname here
# This program contains functions that solve all the problems
# of Homework 6, including a function0() that is given as a 
# bonus.


# function0: receives a string, removes leading and trailing whitespace from
# it, and capitalize all its words, and add two stars at both ends.  Return the
# new string.
def function0( name ):
    name = "**" + name.strip().title() + "**"
    return name


# ================================================
#                                        M A I N
# ================================================
def main():

    # --------------------------------------------------------
    # testing function0() with 3 different strings
    for name in [ "ARTHUR", "  smith COLLEGE  ", " lei   " ]:
        newName = function0( name )
        print( name )
        print( newName )
    print()



if __name__=="__main__":
   main()



</showafterdate>