i
Python functionality and evolution
Installing Python (windows and Ubuntu)
IDLE (Integrated Development and Learning Environment)
Write the first python program and execute it
Keywords in Python
Identifiers in Python
Indentation in Python
Comments in Python
Multi-line Comments in Python
Getting user input
Python Function
Calling a function
Arguments in Function
Scope of Variables
Modules in Python
The PYTHON PATH-Variable
Python File Open
Python File Opening Modes
The file-Object-Attributes
Python File Close() Method
Python File Read/Write
Python File Position
Renaming and Deleting Files in Python
Python Directory Methods
File/Directory Methods
Exceptions in Python
The try-finally Clause
The argument of Exception
Raising Exceptions
Python Built-in Exceptions
Python OOPs Concepts
Python Classes/Objects
Creating Instance Objects
Accessing Attributes
Built-In Class Attributes
Garbage Collection
Python Inheritance
Overriding Methods
Method overriding
Data Hiding
Regular Expression
The match function
The search function
Match Object Methods & Description
Matching or Searching
Search or Replace
Regular Expression Modifiers / Option Flags
Grouping with Parentheses
Python Socket Programming
Python Socket Server
Python Socket Client
Send Data Between Clients
Python Socket or Server
Python Socket Clients
Points to ponder
Introduction
Function is reusable code used to perform any action. For example if any code is concurrently to be used in different program that code to be stored in a function and can be called any times in different programs.
Python has many built in functions like print() type() etc. These are built in function of python which we generally used in any program. Similar way user function can be called that is called user-defined functions.
Defining a Function
Following are the rules of functions:
Function start with keyword def by the function name with parenthesis. For example def test() here def is keyword and test is function followed by parenthesis. Return statement passing back a value. We will discuss with example to understand more clearly. Every function starts with colon (:) as shown in below example/
def (parameters):
…function logic #... is white space or tab after function.
Return[exp]
Example
Below is example of printing a string.
Output:return # it will return string abc and show the result.
Don't miss out!