انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Functions in python

Share |
الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 1
أستاذ المادة هبه امير جابر الخفاجي       28/04/2018 08:09:28
Python Functions
In this lecture, you ll learn about functions; what is a function, the syntax, components and types of a function. Also, you ll learn to create a function in Python.
Table of Contents
? What is a function in Python? o Syntax of Function o Example of a function o How to call a function in python? ? Docstring ? The return statement o Syntax of return o Example of return ? How Function works in Python? ? Scope and Lifetime of variables ? Types of Functions
What is a function in Python?
In Python, function is a group of related statements that perform a specific task.
? Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable. ? Furthermore, it avoids repetition and makes code reusable.

a function definition which consists of following components.
1. Keyword def marks the start of function header. 2. A function name to uniquely identify it. Function naming follows the same rules of writing identifiers in Python. 3. Parameters (arguments) through which we pass values to a function. They are optional. 4. A colon (:) to mark the end of function header. 5. Optional documentation string (docstring) to describe what the function does. 6. One or more valid python statements that make up the function body. Statements must have same indentation level (usually 4 spaces). 7. An optional return statement to return a value from the function.

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم