Denken
Menu
  • About Me
  • Deep Learning with Pytorch
  • Generative AI: Tutorial Series
  • Python Tutorials
  • Contact Me
Menu

Python Tutorials – 1.3 – Functions , Scope Of Variables , Lambda Functions

Posted on September 25, 2017 by Aritra Sen

In Python we have many built-in functions like print() , len() but we can define our own reusable functions which can perform user defined set of operations.

How to define a function:

  • function definition starts with def keyword and followed by function name & ()
  • Within the () we write the input parameters.
  • Followed by : and indentation , we should avoid wrong indentation to avoid code error.
  • end with an optional return statement to return the values from where the function was called , this also exists the function.

Below is an example in the form of code.

Lambda Expression/Functions (Anonymous Functions): 

  • This type functions does not have any names and does not start with def keyword.
  • Lambda functions takes any number of arguments and returns only one value in the form of expression.
  • This function will have only one line.
  • Syntax – lambda arguments: expression
  • Lambda functions are used in combination with in built map & filter functions.
  • Also used in sorting operations.

Now lets look at examples in code & see how to use Lambda expression/functions –

In Maps and filters , we can use other in built or user defined functions.

Category: Python

Post navigation

← Python Tutorials – 1.2 – DataTypes Conversion and Loops
Python Tutorials – 1.4 – Sorting List , Tuple , Dictionary & Zip Function →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RSS Feeds

Enter your email address:

Delivered by FeedBurner

Pages

  • About Me
  • Contact Me
  • Deep Learning with Pytorch
  • Generative AI: Tutorial Series
  • Python Tutorials

Tag Cloud

Announcements Anrdoid BERT Bias Celebration Cricket CyanogenMod deep-learning Denken Experience Facebook Features Finetuning GCN GenerativeAI GNN Google HBOOT HBOOT downgrading HTC Wildfire huggingface India Launch Life LLM Lumia 520 MachineLearning mobile My Space nlp Orkut People Python pytorch pytorch-geometric Rooting Sachin Share Social Network tranformers transformers Tutorials Twitter weight-initialization Windows Phone

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

Categories

Random Posts

  • How to make TweetDeck fast
  • Python Tutorials
  • Deep Learning with Pytorch -Sequence Modeling – Time Series Prediction – RNNs – 3.1
  • Generative AI: LLMs: Semantic Search and Conversation Retrieval QA using Vector Store and LangChain 1.7
  • Generative AI: LLMs: In Context Learning 1.2

Recent Comments

  • Generative AI: LLMs: Reduce Hallucinations with Retrieval-Augmented-Generation (RAG) 1.8 – Denken on Generative AI: LLMs: Semantic Search and Conversation Retrieval QA using Vector Store and LangChain 1.7
  • vikas on Domain Fuss
  • Kajal on Deep Learning with Pytorch -Text Generation – LSTMs – 3.3
  • Aritra Sen on Python Tutorials – 1.1 – Variables and Data Types
  • Aakash on Python Tutorials – 1.1 – Variables and Data Types

Visitors Count

AmazingCounters.com

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright

AritraSen’s site© This site has been protected from copyright by copyscape.Copying from this site is stricktly prohibited. Protected by Copyscape Original Content Validator
© 2025 Denken | Powered by Minimalist Blog WordPress Theme