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

Опубликовано: 06 Август 2021
на канале: 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


На этой странице сайта вы можете посмотреть видео онлайн function parameters - Introduction to Python: Absolute Beginner Module 2 Video 3 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Book Simplifiers 06 Август 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 79 раз и оно понравилось 2 зрителям. Приятного просмотра!