SlideShare a Scribd company logo
1 of 28
Little Coder Program
by
What you’ve learned?
What are loops and how it reduce the effort of reducing instructions
What is for loop and how to iterate with it
What is range() function and how to iterate through lists
How to iterate with while loop
Functions
Re-using your code
Chapter 7
Functions
• A function is a group of statements that together perform a task
• Functions are one way to reuse code—you can use functions in
your programs again and again.
Parts of a Function
• A function has three parts: a name, parameters, and a body.
Here’s an example of a simple function:
>>> def testfunc(myname):
print('hello %s' % myname)
Parts of a Function
• A function has three parts: a name, parameters, and a body.
Here’s an example of a simple function:
>>> def testfunc(myname):
print('hello %s' % myname)
Def is a python keyword
provided for
programmers to create a
python function
Parts of a Function
• A function has three parts: a name, parameters, and a body.
Here’s an example of a simple function:
>>> def testfunc(myname):
print('hello %s' % myname)
Testfunc is the name of
the function. We can
give any name for the
function as per our
convenience
Parts of a Function
• A function has three parts: a name, parameters, and a body.
Here’s an example of a simple function:
>>> def testfunc(myname):
print('hello %s' % myname)
Myname is called as the
parameter of the function. A
parameter is a variable that
exists only while a function is
being used.
Parts of a Function
• A function has three parts: a name, parameters, and a body.
Here’s an example of a simple function:
>>> def testfunc(myname):
print('hello %s' % myname)
This space indicates that we
are going to start a block.
Which is obviously the body
of the function. And in our
body there is only one
statement which is print()
Calling a function
>>> def testfunc(myname):
print('hello %s' % myname)
>>> testfunc('Mary')
Function body or definition
Calling the function
Calling a function
>>> def testfunc(myname):
print('hello %s' % myname)
>>> testfunc('Mary')
Function body or definition
Calling the function
Output
hello Mary
Calling a function
>>> def testfunc(myname):
print('hello %s' % myname)
>>> testfunc('Mary')
The value Mary will be
assigned to the variable
myname during the function
call
Output
hello Mary
Returning a value
• A function is often used to return a value, using a return
statement. For example, you could write a function to calculate
your average mark
>>>def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a=averageMark(35,35,50)
>>>print(a)
40
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>> a=averageMark(35,35,50)
print(a)
Function body or definition
Calling the function
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a=averageMark(35,35,50)
print(a)
If you call the function
averageMark() it will
calculate and return the
average
Calling the function
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a=averageMark(35,35,50)
print(a)
This is where we call the
function averageMark().
We pass three
parameters 35,35,50
during function call
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a=averageMark(35,35,50)
print(a)
This is where we call the
function averageMark().
We call it with three
parameters 35,35,50
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a = averageMark(35,35,50)
print(a)
It calculate and returns
the average value. Ie 40
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a = averageMark(35,35,50)
print(a)
So this selected potion
will be replaced with the
returned value. Ie 40
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a=40
print(a)
So variable a will be
having a value 40
Example Returning a value
>>> def averageMark(science,english,maths)
return (science+english+maths)/3
>>>a=40
print(a) Output
40
Exercise !
Exercise !
• Create a function named “MyDetails()” , calling which will print all the
details about you
• Create a function to calculate the square of any number passed into it
• Crate a function that will return the square of any number passed in to it
End of Chapter 7
What you’ve learned?
What is function ? And how it will help you to reuse your code
What is parameters? How to pass parameter in to a function
How to return a value from a function
Course Exercise !
Write python program to draw below shapes using loops
•
End of little Coder
Hope you are ready to do the teen Coder program
with

More Related Content

What's hot

List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionarynitamhaske
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionarySoba Arjun
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methodsnarmadhakin
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonchanna basava
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...davidwarner122
 
Arrays in python
Arrays in pythonArrays in python
Arrays in pythonmoazamali28
 
Python List Comprehensions
Python List ComprehensionsPython List Comprehensions
Python List ComprehensionsYos Riady
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaEdureka!
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1sotlsoc
 
Python PCEP Function Parameters
Python PCEP Function ParametersPython PCEP Function Parameters
Python PCEP Function ParametersIHTMINSTITUTE
 
Dictionaries and Sets in Python
Dictionaries and Sets in PythonDictionaries and Sets in Python
Dictionaries and Sets in PythonRaajendra M
 

What's hot (20)

List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Sets in python
Sets in pythonSets in python
Sets in python
 
Set methods in python
Set methods in pythonSet methods in python
Set methods in python
 
Python Lecture 8
Python Lecture 8Python Lecture 8
Python Lecture 8
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Python List Comprehensions
Python List ComprehensionsPython List Comprehensions
Python List Comprehensions
 
pyton Notes9
pyton Notes9pyton Notes9
pyton Notes9
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1
 
Tuples in Python
Tuples in PythonTuples in Python
Tuples in Python
 
Python : Regular expressions
Python : Regular expressionsPython : Regular expressions
Python : Regular expressions
 
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M12 - ListsPython Programming Essentials - M12 - Lists
Python Programming Essentials - M12 - Lists
 
Python PCEP Function Parameters
Python PCEP Function ParametersPython PCEP Function Parameters
Python PCEP Function Parameters
 
1. python
1. python1. python
1. python
 
Dictionaries and Sets in Python
Dictionaries and Sets in PythonDictionaries and Sets in Python
Dictionaries and Sets in Python
 

Viewers also liked

Programming Logic for Any Programming Language - Session2
Programming Logic for Any Programming Language - Session2Programming Logic for Any Programming Language - Session2
Programming Logic for Any Programming Language - Session2Mizanur Rahaman Mizan
 
Relations and functions
Relations and functionsRelations and functions
Relations and functionscannout
 
Introduction to Communication Systems 3
Introduction to Communication Systems 3Introduction to Communication Systems 3
Introduction to Communication Systems 3slmnsvn
 
Probability And Stats Intro
Probability And Stats IntroProbability And Stats Intro
Probability And Stats Intromailund
 
Analysis optimization and monitoring system
Analysis optimization and monitoring system Analysis optimization and monitoring system
Analysis optimization and monitoring system slmnsvn
 
Testing, fixing, and proving with contracts
Testing, fixing, and proving with contractsTesting, fixing, and proving with contracts
Testing, fixing, and proving with contractsCarlo A. Furia
 
Function in Maths presention by JASMER BHAN
Function in Maths presention by JASMER BHANFunction in Maths presention by JASMER BHAN
Function in Maths presention by JASMER BHANjasmer1983
 
English grammar in Bangla
English grammar in BanglaEnglish grammar in Bangla
English grammar in BanglaSaidul Hossain
 
Frequency Modulation In Data Transmission
Frequency Modulation In Data TransmissionFrequency Modulation In Data Transmission
Frequency Modulation In Data TransmissionBise Mond
 
Relations and Functions
Relations and FunctionsRelations and Functions
Relations and Functionstoni dimella
 
Fuzzy Set Theory
Fuzzy Set TheoryFuzzy Set Theory
Fuzzy Set TheoryAMIT KUMAR
 
FRM - Level 1 Part 2 - Quantitative Methods including Probability Theory
FRM - Level 1 Part 2 - Quantitative Methods including Probability TheoryFRM - Level 1 Part 2 - Quantitative Methods including Probability Theory
FRM - Level 1 Part 2 - Quantitative Methods including Probability TheoryJoe McPhail
 

Viewers also liked (20)

Linux
Linux Linux
Linux
 
Programming Logic for Any Programming Language - Session2
Programming Logic for Any Programming Language - Session2Programming Logic for Any Programming Language - Session2
Programming Logic for Any Programming Language - Session2
 
Set theory
Set theory Set theory
Set theory
 
04 maths
04 maths04 maths
04 maths
 
Relations and functions
Relations and functionsRelations and functions
Relations and functions
 
All career chart
All career chartAll career chart
All career chart
 
A Simple Guide to Mathematics
A Simple Guide to MathematicsA Simple Guide to Mathematics
A Simple Guide to Mathematics
 
Introduction to Communication Systems 3
Introduction to Communication Systems 3Introduction to Communication Systems 3
Introduction to Communication Systems 3
 
Probability And Stats Intro
Probability And Stats IntroProbability And Stats Intro
Probability And Stats Intro
 
Analysis optimization and monitoring system
Analysis optimization and monitoring system Analysis optimization and monitoring system
Analysis optimization and monitoring system
 
Testing, fixing, and proving with contracts
Testing, fixing, and proving with contractsTesting, fixing, and proving with contracts
Testing, fixing, and proving with contracts
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
 
Function in Maths presention by JASMER BHAN
Function in Maths presention by JASMER BHANFunction in Maths presention by JASMER BHAN
Function in Maths presention by JASMER BHAN
 
Proportional counter
Proportional counterProportional counter
Proportional counter
 
Set Theory In C++
Set Theory In C++Set Theory In C++
Set Theory In C++
 
English grammar in Bangla
English grammar in BanglaEnglish grammar in Bangla
English grammar in Bangla
 
Frequency Modulation In Data Transmission
Frequency Modulation In Data TransmissionFrequency Modulation In Data Transmission
Frequency Modulation In Data Transmission
 
Relations and Functions
Relations and FunctionsRelations and Functions
Relations and Functions
 
Fuzzy Set Theory
Fuzzy Set TheoryFuzzy Set Theory
Fuzzy Set Theory
 
FRM - Level 1 Part 2 - Quantitative Methods including Probability Theory
FRM - Level 1 Part 2 - Quantitative Methods including Probability TheoryFRM - Level 1 Part 2 - Quantitative Methods including Probability Theory
FRM - Level 1 Part 2 - Quantitative Methods including Probability Theory
 

Similar to Baabtra.com little coder chapter - 7

Notes5
Notes5Notes5
Notes5hccit
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptRajasekhar364622
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxSahajShrimal1
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionARVIND PANDE
 
04_python_functions.ppt You can define functions to provide the required func...
04_python_functions.ppt You can define functions to provide the required func...04_python_functions.ppt You can define functions to provide the required func...
04_python_functions.ppt You can define functions to provide the required func...anaveenkumar4
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab FunctionsUmer Azeem
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdfpaijitk
 
Chapter Functions for grade 12 computer Science
Chapter Functions for grade 12 computer ScienceChapter Functions for grade 12 computer Science
Chapter Functions for grade 12 computer ScienceKrithikaTM
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONvikram mahendra
 

Similar to Baabtra.com little coder chapter - 7 (20)

Notes5
Notes5Notes5
Notes5
 
Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.ppt
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
04_python_functions.ppt You can define functions to provide the required func...
04_python_functions.ppt You can define functions to provide the required func...04_python_functions.ppt You can define functions to provide the required func...
04_python_functions.ppt You can define functions to provide the required func...
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
 
Lecture 8.pdf
Lecture 8.pdfLecture 8.pdf
Lecture 8.pdf
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdf
 
Chapter Functions for grade 12 computer Science
Chapter Functions for grade 12 computer ScienceChapter Functions for grade 12 computer Science
Chapter Functions for grade 12 computer Science
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
ex 2.pdf
ex 2.pdfex 2.pdf
ex 2.pdf
 

More from baabtra.com - No. 1 supplier of quality freshers

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 

Recently uploaded (20)

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

Baabtra.com little coder chapter - 7

  • 2. What you’ve learned? What are loops and how it reduce the effort of reducing instructions What is for loop and how to iterate with it What is range() function and how to iterate through lists How to iterate with while loop
  • 4. Functions • A function is a group of statements that together perform a task • Functions are one way to reuse code—you can use functions in your programs again and again.
  • 5. Parts of a Function • A function has three parts: a name, parameters, and a body. Here’s an example of a simple function: >>> def testfunc(myname): print('hello %s' % myname)
  • 6. Parts of a Function • A function has three parts: a name, parameters, and a body. Here’s an example of a simple function: >>> def testfunc(myname): print('hello %s' % myname) Def is a python keyword provided for programmers to create a python function
  • 7. Parts of a Function • A function has three parts: a name, parameters, and a body. Here’s an example of a simple function: >>> def testfunc(myname): print('hello %s' % myname) Testfunc is the name of the function. We can give any name for the function as per our convenience
  • 8. Parts of a Function • A function has three parts: a name, parameters, and a body. Here’s an example of a simple function: >>> def testfunc(myname): print('hello %s' % myname) Myname is called as the parameter of the function. A parameter is a variable that exists only while a function is being used.
  • 9. Parts of a Function • A function has three parts: a name, parameters, and a body. Here’s an example of a simple function: >>> def testfunc(myname): print('hello %s' % myname) This space indicates that we are going to start a block. Which is obviously the body of the function. And in our body there is only one statement which is print()
  • 10. Calling a function >>> def testfunc(myname): print('hello %s' % myname) >>> testfunc('Mary') Function body or definition Calling the function
  • 11. Calling a function >>> def testfunc(myname): print('hello %s' % myname) >>> testfunc('Mary') Function body or definition Calling the function Output hello Mary
  • 12. Calling a function >>> def testfunc(myname): print('hello %s' % myname) >>> testfunc('Mary') The value Mary will be assigned to the variable myname during the function call Output hello Mary
  • 13. Returning a value • A function is often used to return a value, using a return statement. For example, you could write a function to calculate your average mark >>>def averageMark(science,english,maths) return (science+english+maths)/3 >>>a=averageMark(35,35,50) >>>print(a) 40
  • 14. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>> a=averageMark(35,35,50) print(a) Function body or definition Calling the function
  • 15. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a=averageMark(35,35,50) print(a) If you call the function averageMark() it will calculate and return the average Calling the function
  • 16. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a=averageMark(35,35,50) print(a) This is where we call the function averageMark(). We pass three parameters 35,35,50 during function call
  • 17. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a=averageMark(35,35,50) print(a) This is where we call the function averageMark(). We call it with three parameters 35,35,50
  • 18. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a = averageMark(35,35,50) print(a) It calculate and returns the average value. Ie 40
  • 19. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a = averageMark(35,35,50) print(a) So this selected potion will be replaced with the returned value. Ie 40
  • 20. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a=40 print(a) So variable a will be having a value 40
  • 21. Example Returning a value >>> def averageMark(science,english,maths) return (science+english+maths)/3 >>>a=40 print(a) Output 40
  • 23. Exercise ! • Create a function named “MyDetails()” , calling which will print all the details about you • Create a function to calculate the square of any number passed into it • Crate a function that will return the square of any number passed in to it
  • 25. What you’ve learned? What is function ? And how it will help you to reuse your code What is parameters? How to pass parameter in to a function How to return a value from a function
  • 27. Write python program to draw below shapes using loops •
  • 28. End of little Coder Hope you are ready to do the teen Coder program with