Python 3 Tutorial: Introduction To Python Functions

Publicado el: 23 noviembre 2016
en el canal de: Code master
978
12

Be sure to like, share and comment to show your support for our tutorials.

=======================================
Channel - https://goo.gl/pnKLqE
Playlist For This Tutorial - https://goo.gl/EyZFti
Latest Video - https://goo.gl/atWRkF
Facebook -   / mastercodeonline  
Twitter - https://twitter.com/mastercodeonlin?l...
Website - http://mastercode.online
======================================

Introduction To Python Functions

In this Pro Python Programmer tutorial section, we will be providing an introduction to Python functions. In the previous, one hundred or so Python tutorials we worked with some functions in our statements which were created by other programmers. In this section, we will show you how to create your own functions. You will soon learn how important Python functions are in everyday programming. Before you dive into this Python tutorial. I want you to enter this tutorial with an open mind. Functions may look intimidating at first but in fact they are very simple.

What Is A Function In Python?

A function is a block of code that contains other Python code that can be called throughout a Python program and may take parameters to compute a result. These parameters may change each time the code is ran which would provide different results.

Python is a great supporter of the DRY concept which means "Don't Repeat Yourself". Functions help us perform a task in our Python programs without repeating our code over and over. When writing a program in Python, if you are required to write the same code more once then you are probably better off putting the code in a function and then calling the function by the functions name to use that code. Remember DRY plays an important role in programming. If you are repeating yourself, you probably are doing something wrong.

Why Functions?

The main reason we use functions in Python is code reusability. If you have a strict coding structure which means you code with a strict pattern of rules you will never need to rewrite the same function over again. When I write a function I have a tendency to put them in a directory on my computer and if I ever need to rewrite that function again I can just grab that function and through it into my current project. This is utilizing reusability to its fullest.

Now that we understand that functions are a critical tool for the lazy programmer like myself. Functions also enable us to break our code down into a procedural process of functions. For example, if we were to a program that changed light bulbs our code structure would probably go in this order. First function would turn off the light switch, next function would twist the light bulb out of the socket, third function would get a new bulb, fourth function would tighten a new light bulb in and the last function would turn the light switch on.

With the procedure programming in mind I have a tendency to list out my functions ahead of time. This enables me to plan my course of action when approaching a coding issue. If you think of each function of as a step to complete a programming task your code will be well structured and you will avoid headaches down the road.


En esta página del sitio puede ver el video en línea Python 3 Tutorial: Introduction To Python Functions de Duración hora minuto segunda en buena calidad , que subió el usuario Code master 23 noviembre 2016, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 978 veces y le gustó 12 a los espectadores. Disfruta viendo!