Changes between Version 68 and Version 69 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 4, 2017, 9:59:45 PM (8 years ago)
Author:
cdelgigante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v68 v69  
    269269Run this one.  What does it output?  A lovely happy birthday song for two kids?   Now imagine if you had to write a program to print out a happy birthday for every single person in your grade without it.  It'd get pretty ugly, fast.
    270270
    271 `def` is used in Python to indicate a custom function, and you have to ''def''ine it in your program before you use it.  It takes an argument of an age, and second argument of a list of names.  The "singHappyBirthday" line actually ''calls'' the custom function, with the two arguments it needs.
    272 
    273 A function can return a value, by using the Python keyword `return` as in:
     271The keyword `def` is used in Python to indicate a custom function, and you have to ''def''ine it in your program before you use it.  This function takes an argument of an age, and second argument of a list of names.  The "singHappyBirthday" line at the end actually ''calls'' or runs the custom function, with the two arguments it needs.
     272
     273A function can return a value too, by using the Python keyword `return` for example:
    274274
    275275{{{
     
    285285}}}
    286286
    287 Now your turn...  Modify the 'That's-a big number" exercise above, adding a custom function called called inputNumber to input one number, and use it instead of repeating the while-not stuff.  Much easier to read, no?
     287Now your turn...  Modify the 'That's-a big number" exercise above, adding a custom function called called inputNumber to input one number, and use it instead of repeating the while-not stuff.  Run it and verify the output is the same.  Much easier to read, no?
    288288
    289289Here's the [[ThatsaBigNumberSolution|solution]]