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

Veröffentlicht am: 06 August 2021
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video function parameters - Introduction to Python: Absolute Beginner Module 2 Video 3 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Book Simplifiers 06 August 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 79 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!