The document discusses functions in Python. Some key points:
1. Functions allow programmers to split large programs into smaller, reusable units of code. This makes programs easier to understand, test, and maintain.
2. There are different types of functions like built-in functions, user-defined functions, and library functions that contain generic code.
3. Functions can take parameters and return values. Parameters are placeholders for values passed to the function while arguments are the actual values passed.
4. Functions have scopes that determine where variables are accessible. Local scope only allows access within the function while global scope allows access anywhere.
Operator Overloading and Scope of VariableMOHIT DADU
This slide is completely based on the Operator Overloading and the Scope of Variable. The example given to explain are based on C/C++ programming language.
LESSON 4: INTRODUCING FUNCTIONS AND MODULAR DESIGN
Learn about Functions in Python. Advantages and disadvantages of functions. Introduction to Modular design. Local and Global Variables and their use. Passing parameters. What are arguments? Big questions: Evolution vs Intelligent design in light of functions (and modular design). A closer look at Robotics and advances in this field. Challenges and tasks including with solutions. Suggested research/HW and YouTube video recommendations. A note on Python’s built in functions.
slide1: the content of functons
slide2: Introduction to function
slide3:function advantages
slide4 -5: types of functions
slide6: elements of user defined functions
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Operator Overloading and Scope of VariableMOHIT DADU
This slide is completely based on the Operator Overloading and the Scope of Variable. The example given to explain are based on C/C++ programming language.
LESSON 4: INTRODUCING FUNCTIONS AND MODULAR DESIGN
Learn about Functions in Python. Advantages and disadvantages of functions. Introduction to Modular design. Local and Global Variables and their use. Passing parameters. What are arguments? Big questions: Evolution vs Intelligent design in light of functions (and modular design). A closer look at Robotics and advances in this field. Challenges and tasks including with solutions. Suggested research/HW and YouTube video recommendations. A note on Python’s built in functions.
slide1: the content of functons
slide2: Introduction to function
slide3:function advantages
slide4 -5: types of functions
slide6: elements of user defined functions
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
2. Introduction
Large programs are often difficult to manage, thus large programs are
divided into smaller unitsknownas functions.
It issimply a group of statements under any namei.e. function nameand canbe
invoked(call) from other part of program.
T
ake an example of School Management Software, now this software will
contain various tasks like Registering student, Fee collection, Library book issue,
TC generation, Result Declaration etc. In this case we have to create different
functionsfor eachtask to manage the software development.
3. Introduction
Set of functions is stored in a file called MODULE. And this approach is
knownasMODULARIZATION, makesprogram easier to understand,test
and maintain.
Commonly used modules that contain source code for generic need are
called LIBRARIES.
Modulescontains setof functions.Functionsisof mainly two types:
Built-in Functions
4. Advantages of Function
PROGRAM HANDLING EASIER: only small part of the program is dealt with
at a time.
REDUCEDLoC:aswith functionthe commonsetof code iswritten only onceand
canbe called from any part of program, soit reducesLineof Code
EASY UPDATING : if function is not used then set of code is to be repeated
everywhere it is required. Hence if we want to change in any
formula/expression then we have to make changes to every place, if
forgotten then output will be not the desired output. With function we have to
5. UserDefinedFunctions
A function is a set of statements that performs a specific task; a common
structuring elements that allows you to use a piece of code repeatedly in
different part of program. Functions are also known as sub-routine, methods,
procedure or subprogram.
Syntax to create USERDEFINEDFUNCTION
def function_name([commaseparated list of parameters]):
statements…. statements….
KEYWORD FUNCTIONDEFINITION
6. Pointstoremember…
Keyword def marksthe start of function header
Functionnamemustbe uniqueand follows namingrules sameasfor
identifiers
Functioncantake arguments.It isoptional
A colon(:) to mark the end of function header
Functioncancontainsoneor morestatementto perform specific task
Anoptional returnstatementto return a value from the function.
Functionmustbe called/invoked to execute its code
7. UserDefined function can be….
1. Functionwith noargumentsand noreturn
2. Function with argumentsbut no returnvalue
3. Function with argumentsand return value
4. Function with no argument but return value
8. Function with no argument and no return
Thistype of function isalso knownasvoid function
FUNCTIONNAME NO P
ARAMETER,HENCEVOID
Returnkeyword notused
FUNCTIONCALLING,ITWILLINVOKEwelcome()TO PERFORMITSACTION
9. Functionwithparametersbutno return value
Parametersare given in the parenthesisseparated by comma.
Valuesare passedfor the parameter at the time of function
calling.
11. Functionwith parameter and return
We canreturn values from function usingreturn
keyword.
Thereturn value mustbe usedat the calling place by
–
Eitherstore it any variable
Usewith print()
Usein any expression
13. Functionwithreturn
NOTE:the return statement ends a
functionexecutionevenif it is inthe
middleof function. Anythingwritten
below return statement will
become unreachable code.
def max(x,y):
if x>y:
returnx
else:
returny
print(“Iam not reachable”)
14. ParametersandArgumentsin Function
Parameters are the value(s) provided in the parenthesis when we write
function header. Theseare the values required by function to work
If there are morethan oneparameter, it mustbe separated by comma(,)
An Argument is a value that is passed to the function when it is called. In
other words arguments are the value(s) provided in function call/invoke
statement
Parameter isalso knownasFORMAL ARGUMENTS/PARAMETERS
Arguments is also known as ACTUAL ARGUMENTS/PARAMETER
Note: Functioncanalter only MUTABLETYPEvalues.
17. Positional arguments
Are argumentspassedto a function in correct positional
order
Here x ispassedto a and y ispassedto b i.e. in the order of their position
19. Default arguments
Sometimes we can provide default values for our positional
arguments. In this case if we are not passing any value then default
valueswill be considered.
Default argumentmustnotfollowed by non-default arguments.
def interest(principal,rate,time=15):
def interest(principal,rate=8.5,time=15):
def interest(principal,rate=8.5,time):
VALID
INVALID
21. Keyword(Named)Arguments
The default keyword gives flexibility to specify default value for a
parameter so that it can be skipped in the function call, if needed.
However, still we cannot change the order of arguments in function
call i.e. you have to remember the order of the arguments and pass
the value accordingly.
T
oget control and flexibility over the values sent as arguments, python
offers KEYWORDARGUMENTS.
This allows to call function with arguments in any order using name of
23. Rules forcombining all threetypeof
arguments
Anargumentlist mustfirst contain positional arguments
followed by keyword arguments
Keyword argumentsshouldbe taken from the required
arguments
Y
oucannotspecify a value for an argumentmore than once
24. Exampleof legal/illegal function call
FUNCTION CALL LEGAL/
ILLEGAL
REASON
Average(n2=20, n1=40,n3=80) LEGAL Nondefault values provided as
named arguments
Average(100,200,n1=300) LEGAL Keyword argument canbe in any
order
Average(100,n2=10,n3=15) LEGAL Positional argument before the
keyword arguments
Average(n3=70,n1=90,100) ILLEGAL Keyword argument before the
positional arguments
Average(100,n1=23,n2=1) ILLEGAL Multiple values provided for n1
def Average(n3,n2,n1=200):
return(n1+n2+n3)/3
25. ReturningMultiple values
Unlikeother programming languages,python lets youreturn
morethanonevalue from function.
Themultiple return value mustbe either stored in TUPLEor wecan
UNP
ACKthe received value by specifying the samenumberof
variables onthe left of assignmentof function call.
28. Scopeof
Variables
SCOPE means in which part(s) of the program, a
particular piece of code or data isaccessible or known.
InPython there are broadly 2 kinds of Scopes:
Global Scope
Local Scope
29. Global Scope
A name declared in top level segment( main ) of a program is
said to haveglobal scopeand canbe usedin entire program.
Variable defined outsideall functionsare global variables.
Aname declare in a function body is said to have local scope i.e. it can be
usedonly within this function and the other block inside the function.
Theformal parameters are also having local scope.
Local Scope
31. Example– Localand Global Scope
“a‟isnot accessible
here becauseit is
declared infunction
area(), soscopeis
local to area()
32. Example– Localand Global Scope
Variable "ar‟ is accessible in
function showarea() because
it ishaving Global Scope
33. Thisdeclaration “global count” is
necessaryfor usingglobal
variables in function, other wise an
error “local variable 'count'
referenced before assignment”
will appear becauselocal scope
will create variable “count” and it
will be found unassigned
34. Lifetime of Variable
Isthe time for whicha variable livesinmemory.
For Global variables the lifetime isentire program run
i.e. aslong asprogram isexecuting.
• For Local variables lifetime is their function‟s run i.e. as long as
function isexecuting.
35. NameResolution(ScopeResolution)
Forevery nameusedwithin program python follows nameresolutionrules knownasLEGB rule.
(i) LOCAL : first check whether name is in local environment, if yes Python uses its value
otherwise moves to (ii)
(ii) ENCLOSING ENVIRONMENT: if not in local, Python checks whether name is in Enclosing
Environment,if yes Python uses its value otherwise moves to (iii)
GLOBAL ENVIRONMENT: if not in above scope Python checks it in Global environment, if yes
Python uses itotherwise moves to (iv)
BUILT-IN ENVIRONMENT: if not in above scope, Python checks it in built-in environment, if
yes, Python uses its value otherwise Python would reportthe error:
name<variable> notdefined
46. Mutability/Immutability of
Arguments/Parameters and function call
Fromthe previous example we can recall the concept learned in classXI
that Python variables are not storage containers, rather Python
variables are like memory references, they refer to memory address
where the value is stored, thus any change in immutable type data
will also change the memory address. So any change to formal
argument will not reflect back to its corresponding actual argument
and in case of mutable type, any change in mutable type will not
change thememory address of variable.
47. Mutability/Immutability of
Arguments/Parameters and function call
Because List if Mutable type, hence any change in formal
argument myList will not change the memory address, So
changes done tomyListwill be reflectedback to List1.
Howeverif weformalargumentisassignedtosomeothervariableordatatype then
linkwillbreakandchangeswillnotreflectbacktoactualargument
Forexample (if inside function updateData() we assign myList as:
myList = 20 OR myList = temp
48. PassingString to function
Functioncanaccept string asa parameter
As per Python, string is immutable type, so function can access the
value of string but cannotalter the string
T
o modify string, the trick is to take another string and concatenate
the modified value of parameter string in the newly created string.
52. PassingListto function
We canalso passListto any function asparameter
Dueto the mutable nature of List,function canalter the list of
valuesin place.
It ismostlyusedin data structurelike sorting, stack, queue etc.
58. Passingtuples to function
We can also passtuples to function as parameter
Dueto its immutability nature, function can only access
the values of tuples but cannot modify it.
59. Creating a login program with the
help of passing tuple to
function
60. Creating a login program with the
help of passing tuple to
function
OUTPUTOFPREVIOUSPROGRAM
61. Input n numbers in tuple and pass it function to
count howmanyevenand odd numbersare
entered.
62. Input n numbers in tuple and pass it function to
count howmanyevenand odd numbersare
entered.
63. PassingDictionary to function
Pythonalso allows usto passdictionaries to function
Dueto its mutability nature,function canalter the keysor values
of dictionary in place
Letusseefew examples of howto passdictionary to functions.
64. P
assing dictionary to function with list and stores the
value of list as key and its frequency or no. of
occurrenceasvalue