function parameters - Introduction to Python: Absolute Beginner Module 2 Video 3

Pubblicato il: 06 agosto 2021
sul canale di: Book Simplifiers
79
2

Concept: Function Parameters
Functions that have Parameters
print() and type() are examples of built-in functions that have Parameters defined

type() has a parameter for a Python Object and sends back the type of the object

an Argument is a value given for a parameter when calling a function

type is called providing an Argument - in this case the string "Hello"
type("Hello")
Defining Function Parameters
Parameters are defined inside of the parenthesis as part of a function def statement
Parameters are typically copies of objects that are available for use in function code
def say_this(phrase):
print(phrase)
Function can have default Arguments
Default Arguments are used if no argument is supplied
Default arguments are assigned when creating the parameter list
def say_this(phrase = "Hi"):
print(phrase)
Example
yell_this() yells the string Argument provided
def yell_this(phrase):
print(phrase.upper() + "!")

call function with a string
yell_this("It is time to save the notebook")
use a default argument
def say_this(phrase = "Hi"):
print(phrase)

say_this()
say_this("Bye")
Task 3
Define yell_this() and call with variable argument
define variable words_to_yell as a string gathered from user input()
Call yell_this() with words_to_yell as argument
get user input() for the string words_to_yell
[ ] define yell_this()

[ ] get user input in variable words_to_yell

[ ] call yell_this function with words_to_yell as argument


In questa pagina del sito puoi guardare il video online function parameters - Introduction to Python: Absolute Beginner Module 2 Video 3 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Book Simplifiers 06 agosto 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 79 volte e gli è piaciuto 2 spettatori. Buona visione!