课程: Programming Concepts for Python
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Multiple parameters
- Sometimes my wife finds fancy recipes for omelettes on the internet that she likes to try out. - Hey, how do you feel about an omelette with sausage, onions, peppers, spinach, mushrooms, tomatoes, and goat cheese? - No problemo. I'll just use the make omelette function. Actually, there will be a problem. Make omelette only takes one ingredient as input, and Olivia's recipe has way more ingredients than that. In this case, it may be wise to not limit ourselves to only using one extra ingredient. - [Olivia] One way we can add more ingredients to our Python omelette is by adding more input parameters to the function definition. So instead of having just one input named ingredient, we can give the function two inputs named ingredient1 and ingredient2. When a function has multiple parameters, it's important that each parameter has a unique name so we can reference them individually inside the function. Now that we've given…