Basic Python 24: Python Function Arguments Positional, Keywords and Default

Veröffentlicht am: 01 Oktober 2022
auf dem Kanal: Testing Tutorialspoint
24
6

Python Function Arguments: Positional, Keywords and Default

Arguments:
----------
def greet(name, msg):
"""This function greets to
the person with the provided message"""
print("Hello", name + ', ' + msg)

greet("Monica", "Good morning!")

Variable Function Arguments:
----------------------------
functions had a fixed number of arguments. In Python, there are other ways to define a function that can take variable number of arguments.

Three different type forms

Python Default Arguments:

ex:
def greet(name, msg="Good morning!"):
"""
This function greets to
the person with the
provided message.

If the message is not provided,
it defaults to "Good
morning!"
"""

print("Hello", name + ', ' + msg)


greet("Kate")
greet("Bruce", "How do you do?")

Python Keyword Arguments:
-------------------------
2 keyword arguments
greet(name = "Bruce",msg = "How do you do?")

2 keyword arguments (out of order)
greet(msg = "How do you do?",name = "Bruce")

1 positional, 1 keyword argument
greet("Bruce", msg = "How do you do?")

Python Arbitrary Arguments:
---------------------------
we do not know in advance the number of arguments that will be passed into a function. Python allows us to handle this kind of situation through function calls with an arbitrary number of arguments.

In the function definition, we use an asterisk (*) before the parameter name to denote this kind of argument.
ex:
def greet(*names):
"""This function greets all
the person in the names tuple."""

names is a tuple with arguments
for name in names:
print("Hello", name)


greet("Monica", "Luke", "Steve", "John")

__________________ API Automation _________________
➡️ Rest Assured Using Java →    • Rest Assured  
➡️ Karate Framework using Maven →    • Karate Framework Using Maven Project  
_____________ Programing Language ____________________
➡️ Basic Python →    • Basic Python  
➡️ Core Java →    • CoreJava  
___________ Performances Testing ___________________
➡️ JMeter Beginner →    • JMeter Beginner  
➡️ Locust Beginner →    • Locust  
___________ Git and GitHub _____________________________
➡️ Git and GitHub Beginner →    • Git and GitHub Beginner  

_____________Manual Testing ____________________
➡️ Manual Testing →    • Manual Testing  

______________Automation Testing __________________
➡️ Selenium Cucumber Framework using Java →    • Selenium Cucumber BDD Framework with Java ...  
➡️ Robot Framework with Python →    • Python With Robot Framework  
➡️ Beginner Karate Framework using Intellij →    • Karate Framework Beginner  
➡️ Karate Framework with Gradle using eclipse →    • Karate Framework using Gradle Project  
➡️ Basic Selenium WebDriver using Java →    • Selenium WebDriver  
➡️ TestNG Framework →    • TestNG Framework  
➡️ Robot Framework with RIDE →    • RIDE With Robot Framework  
________________ Beginner Jenkins ____________________
➡️ Beginner Jenkins →    • Beginner Jenkins  


Auf dieser Seite können Sie das Online-Video Basic Python 24: Python Function Arguments Positional, Keywords and Default mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Testing Tutorialspoint 01 Oktober 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 24 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!