What are Functions in Python? (Definition & Syntax) - Python Tutorial for Beginners

Pubblicato il: 15 aprile 2021
sul canale di: Digital Academy
749
10

🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!

🖥️ What are Functions in Python? Definition & Syntax for Beginners

Function in Python is a group of related statements, that performs a specific task. Each function helps break your program into pieces of smaller and modular chunks. As your program grows larger and larger, functions in Python make it more organized. Furthermore, functions avoid repetition, make the code reusable and allow you to work collaboratively.

That's True! Functions are the first step to code reuse. They allow you to define a reusable block of code, that can be used, repeatedly in your program. Actually, Python provides several built-in functions, such as: print(), len() or type(). But, you can also define your own functions to use within your programs in Python.


○ Syntax of Function in Python

The basic definition of a Function in Python is as follows:

1. Keyword def, that marks the start of the function header.
2. Function name, to uniquely identify the function throughout your program.
3. Optional parameters (arguments), through which you pass values to a function.
4. Colon (:), to mark the end of the function header.
5. Optional documentation string (docstring) to describe what the function does.
6. One or more valid Python statements in the function body, with the same indentation level - usually 4 spaces.
7. Optional return statement, to return a value from the function.


○ Example of a Function in Python

def hello(name):
"""
This function greets to
the person passed in as
a parameter
"""
print(f"Hello, {name}. Keep watching!")


Let's play this video, stick around and watch until the end of this video! 👍🏻

Digital Academy™ 🎓

***

☞ WATCH NEXT:
○ Data Types in Python -    • DATA TYPES in Python (Numbers, Strings, Li...  
○ Operators in Python -    • OPERATORS in Python (Arithmetic, Assignmen...  
○ IF Statements in Python -    • CONDITIONAL Statements in Python (IF, ELIF...  
○ FOR Loops in Python -    • FOR Loop in Python (Syntax, Break, Continu...  

📖 Blog: http://digital.academy.free.fr/blog

📖 [FULL Course] HOW TO Learn Python? Python Tutorial for Beginners:    • 🐍 Python 101: Learn Python Basics for Abso...  

📖 [PLAYLIST] Complete Python Development Course for Beginners: http://digital.academy.free.fr/playli...

🧑‍🎓 [COURSE] http://digital.academy.free.fr/courses

📘 [BOOK] Python for Absolute Beginners: https://amzn.to/3NvyOWV

🛒 Shopping and Discounts: http://digital.academy.free.fr/store

💌 Weekly Newsletter for Developers: https://www.getrevue.co/profile/digit...

#Python #Tutorial #Beginners #Shorts

***

♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.

***

♡ FOLLOW US ♡
✧ http://digital.academy.free.fr/
✧   / digitalacademyy  
✧   / digitalacademyfr  
✧   / digital_academy_fr  
✧    / digitalacademyonline  

♡ SUPPORT US ♡
✧ http://digital.academy.free.fr/join
✧ http://digital.academy.free.fr/store
✧ http://digital.academy.free.fr/donate
✧ http://digital.academy.free.fr/subscribe
✧   / digital_academy  
✧ https://www.buymeacoffee.com/digital_...

***


In questa pagina del sito puoi guardare il video online What are Functions in Python? (Definition & Syntax) - Python Tutorial for Beginners della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Digital Academy 15 aprile 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 749 volte e gli è piaciuto 10 spettatori. Buona visione!