The document discusses functions in Python. It states that large programs can be divided into smaller and more manageable units called functions. Functions allow code to be reused by calling the function from different parts of a program. The document covers the different types of functions like functions with and without parameters and return values. It also discusses scopes of variables, parameter passing, and composing functions.
Computer science notes of functions chapterGodzilla33
The document discusses functions in Python. It states that large programs are divided into smaller units called functions to make them easier to manage. Functions allow code to be reused by calling the function from different parts of a program. There are several types of functions: functions with no arguments or return value, functions with arguments but no return, and functions with both arguments and a return value. Functions make programs easier to understand, test and maintain. Modularization involves storing functions in a file called a module. Commonly used modules containing generic functions are called libraries.
This document provides an overview of conditional and iterative statements in Python. It discusses the different types of statements in Python including empty, simple, and compound statements. It also covers flow control statements like sequence, selection, and iteration. Specific conditional statements like if, elif, else are explained along with examples. Iteration statements like for and while loops are also introduced. The document concludes with a discussion of errors and exceptions in Python.
Functions allow programmers to organize code into reusable units and divide large programs into smaller, more manageable parts. The document discusses key concepts related to functions in Python like defining and calling user-defined functions, passing arguments, scope, and recursion. It provides examples of different types of functions and how concepts like mutability impact parameter passing. Functions are a fundamental part of modular and readable program design.
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.
This document discusses how to connect a Python application to a MySQL database. It explains that the mysql.connector package must be installed first to create the connection bridge between Python and MySQL. It then outlines the steps to connect to a MySQL database from Python code, including importing mysql.connector, opening a connection, creating a cursor, executing queries, and extracting data from the result set. It also provides examples of inserting, updating, and parameterized queries.
Functions allow programmers to organize and reuse code. They take in parameters and return values. Parameters act as variables that represent the information passed into a function. Arguments are the actual values passed into the function call. Functions can have default parameter values. Functions can return values using the return statement. Python passes arguments by reference, so changes made to parameters inside functions will persist outside the function as well. Functions can also take in arbitrary or keyword arguments. Recursion is when a function calls itself within its own definition. It breaks problems down into sub-problems until a base case is reached. The main types of recursion are direct, indirect, and tail recursion. Recursion can make code more elegant but uses more memory than iteration.
These functions are created by the programmer as needed to perform specific tasks within their program. They allow the programmer to encapsulate a set of statements into a single block that can be called whenever necessary. User-defined functions help in modularizing the code, making it easier to read, understand, and maintain.These functions are part of the programming language's standard library and are available for use without requiring the programmer to define them. They serve various purposes and are commonly used for tasks like mathematical operations, string manipulation, sorting, and more.Remember, functions aid in organizing code, improving readability, and promoting code reusability, which are crucial aspects of efficient programming and software development.
The document discusses functions in Python. It defines what a function is and explains that functions allow programmers to organize code into reusable blocks to perform specific tasks. It categorizes functions into three types: built-in functions, module functions, and user-defined functions. Several examples of built-in functions are provided like type conversion functions, math functions, and random functions. The document also explains how to define and call user-defined functions, how to pass arguments to functions, and the different types of arguments like positional, default, keyword, and variable length arguments.
Computer science notes of functions chapterGodzilla33
The document discusses functions in Python. It states that large programs are divided into smaller units called functions to make them easier to manage. Functions allow code to be reused by calling the function from different parts of a program. There are several types of functions: functions with no arguments or return value, functions with arguments but no return, and functions with both arguments and a return value. Functions make programs easier to understand, test and maintain. Modularization involves storing functions in a file called a module. Commonly used modules containing generic functions are called libraries.
This document provides an overview of conditional and iterative statements in Python. It discusses the different types of statements in Python including empty, simple, and compound statements. It also covers flow control statements like sequence, selection, and iteration. Specific conditional statements like if, elif, else are explained along with examples. Iteration statements like for and while loops are also introduced. The document concludes with a discussion of errors and exceptions in Python.
Functions allow programmers to organize code into reusable units and divide large programs into smaller, more manageable parts. The document discusses key concepts related to functions in Python like defining and calling user-defined functions, passing arguments, scope, and recursion. It provides examples of different types of functions and how concepts like mutability impact parameter passing. Functions are a fundamental part of modular and readable program design.
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.
This document discusses how to connect a Python application to a MySQL database. It explains that the mysql.connector package must be installed first to create the connection bridge between Python and MySQL. It then outlines the steps to connect to a MySQL database from Python code, including importing mysql.connector, opening a connection, creating a cursor, executing queries, and extracting data from the result set. It also provides examples of inserting, updating, and parameterized queries.
Functions allow programmers to organize and reuse code. They take in parameters and return values. Parameters act as variables that represent the information passed into a function. Arguments are the actual values passed into the function call. Functions can have default parameter values. Functions can return values using the return statement. Python passes arguments by reference, so changes made to parameters inside functions will persist outside the function as well. Functions can also take in arbitrary or keyword arguments. Recursion is when a function calls itself within its own definition. It breaks problems down into sub-problems until a base case is reached. The main types of recursion are direct, indirect, and tail recursion. Recursion can make code more elegant but uses more memory than iteration.
These functions are created by the programmer as needed to perform specific tasks within their program. They allow the programmer to encapsulate a set of statements into a single block that can be called whenever necessary. User-defined functions help in modularizing the code, making it easier to read, understand, and maintain.These functions are part of the programming language's standard library and are available for use without requiring the programmer to define them. They serve various purposes and are commonly used for tasks like mathematical operations, string manipulation, sorting, and more.Remember, functions aid in organizing code, improving readability, and promoting code reusability, which are crucial aspects of efficient programming and software development.
The document discusses functions in Python. It defines what a function is and explains that functions allow programmers to organize code into reusable blocks to perform specific tasks. It categorizes functions into three types: built-in functions, module functions, and user-defined functions. Several examples of built-in functions are provided like type conversion functions, math functions, and random functions. The document also explains how to define and call user-defined functions, how to pass arguments to functions, and the different types of arguments like positional, default, keyword, and variable length arguments.
The document discusses functions in Python. It introduces functions as a way to divide large programs into smaller, more manageable units called functions. Functions allow code to be reused by calling or invoking the function from different parts of a program. The document then covers key concepts related to functions like arguments, parameters, scope, recursion, and more. It provides examples to illustrate different types of functions and how concepts like scope, recursion, and argument passing work.
Functions allow programmers to organize code into reusable blocks. A function performs a specific task and can accept input parameters and return an output. Functions make code more modular and easier to maintain. Functions are defined with a name, parameters, and body. They can be called from other parts of the code to execute their task. Parameters allow functions to accept input values, while return values allow functions to return output to the calling code. Functions can be called by passing arguments by value or reference. The document provides examples and explanations of different types of functions in C++ like inline functions, functions with default arguments, and global vs local variables.
What's new and changed in PHP 8.
- Major new changes in PHP 8
- New functions and classes
- OOP improvements
- Type system improvements
- Error handling improvements
- Resource to Object migration
- String related changes
- Removed functionality
https://php.watch/versions/8.0
The document introduces functions in C programming. It discusses defining and calling library functions and user-defined functions, passing arguments to functions, returning values from functions, and writing recursive functions. Functions allow breaking programs into modular and reusable units of code. Library functions perform common tasks like input/output and math operations. User-defined functions are created to perform specific tasks. Information is passed between functions via arguments and return values.
PHP is a relatively easy language to learn if you are familiar with HTML/CSS. Here, and following, are the presentations to familiarize yourself with PHP/MySQL and HTML Basics.
A Python module is a file containing Python code such as functions, classes, and variables that can be imported and used in other Python programs. The document discusses several key aspects of Python modules including their structure, importing modules, and built-in modules like the math, random, and statistics modules. The math module contains common mathematical functions, the random module generates random numbers, and the statistics module calculates statistical values like the mean, median, and mode of data sets.
This document discusses functions in C programming. It defines functions as a group of statements that perform a specific task and have a name. Main functions must be included in every C program as it is where program execution begins. Functions help facilitate modular programming by dividing programs into smaller parts. Functions can be user-defined or built-in library functions. Parameters can be passed to functions by value or by reference. Functions can call themselves through recursion. Variables have different storage classes like auto, register, static, and external that determine scope and lifetime.
In this file, MarsDevs illustrates functions in Python, the function argument, and the keyword argument. We use various examples with code to understand the concept better.
Click here to know more: https://www.marsdevs.com/blogs/functions-and-arguments-in-python
This document discusses user-defined functions in C++. It covers value-returning functions, the return statement, function prototypes, and flow of execution. Standard (predefined) functions are discussed as well as advantages of using functions such as modularity, reusability, and the ability to focus on individual parts of a program. Function definitions require a heading specifying return type, name, and parameters, as well as a function body and return statement.
Functions allow for code reusability and modularity by defining reusable blocks of code. A function is defined using the def keyword followed by the function name and parameters. Functions can take in arguments and return values. There are different types of arguments like default arguments, keyword arguments, positional arguments, and arbitrary arguments. Functions improve efficiency and reduce errors through code reuse.
This document discusses user-defined functions in C++. It covers defining functions with return types and parameters, using return statements, function prototypes, and the flow of execution when a function is called. Functions help make programs more modular and understandable by breaking tasks into reusable blocks of code. Defining functions properly allows the compiler to understand how to execute function calls within a program.
This presentation educates you about the Functions of the Python, Defining a Function, Calling a Function, Pass by reference vs value, Pass by reference vs value, Required arguments, Keyword arguments, Default arguments and Variable-length arguments.
For more topics stay tuned with Learnbay.
The document discusses functions in C programming. It defines functions as segments of a program that perform well-defined tasks and can be called independently. Functions make programs modular and easier to write, test and maintain. Key points covered include: functions have a name and signature; parameters are passed between calling and called functions; the return statement ends function execution and returns control/values; parameters can be passed by value or reference.
User Defined Function in C
- Functions modularize programs and allow for code reusability. Parameters allow communication between functions.
- A function definition includes a return type, name, parameters, and block of statements. Functions are called within other functions.
- Functions provide benefits like divide and conquer programming, manageable development, and abstraction that hides internal details.
Python functions allow breaking down code into reusable blocks to perform tasks. There are several types of functions including built-in, user-defined, and anonymous functions. User-defined functions are defined using the def keyword and can take in parameters. Functions can return values using the return statement. Functions are called by their name along with any arguments. Arguments are passed into parameters and can be positional, keyword, or have default values. Functions increase code reuse and readability.
This document discusses PHP functions and how to define, call, and use them. It covers defining functions, arguments and parameters, default argument values, variable scope, and including library files. Functions allow reusable blocks of code and avoid duplicating code. Arguments are values passed into a function, while parameters are variable names used inside the function. Default arguments can be set so functions still work if not all arguments are passed. Variable scope determines where variables can be accessed. Library files allow storing functions in one place and including them elsewhere.
The document discusses various control structures in PHP including functions, variable scope, conditional statements, loops, and include/require statements. Functions allow you to organize your code into reusable blocks. Variable scope determines where a variable can be accessed. Conditional statements like if/else and switch allow executing different code blocks based on conditions. Looping statements like while, do-while, and for repeatedly execute a code block. Include/require is used to include the contents of another file.
This document provides an overview of several advanced Python concepts including generators, iterators, decorators, exceptions handling, SQLAlchemy ORM, and unit testing. Generators allow creating iterators using the yield keyword to pause and resume function execution. Decorators dynamically alter function behavior. Exceptions handling uses try/catch blocks. SQLAlchemy is an ORM for Flask applications. Unit testing ensures code works as expected using libraries like unittest and nose.
The document discusses user-defined functions in C++. It explains that a function allows structuring programs in a modular way by grouping statements that are executed when the function is called. The format of a function includes its return type, name, parameters, and function body enclosed in curly braces. Functions can be called by passing arguments, which are copied to the function's local parameter variables. Functions can return a single value. Function prototypes declare a function's interface without defining its body, allowing a function to be called before it is defined. Arguments can be passed by value, where copies are passed, or by reference, where the function can modify the original variables. Arrays can be passed to functions by only passing the array name
This document discusses different types of functions in C programming. It defines library functions, user-defined functions, and the key elements of functions like prototypes, arguments, parameters, return values. It categorizes functions based on whether they have arguments and return values. The document also explains how functions are called, either by value where changes are not reflected back or by reference where the original values are changed.
When it is all about ERP solutions, companies typically meet their needs with common ERP solutions like SAP, Oracle, and Microsoft Dynamics. These big players have demonstrated that ERP systems can be either simple or highly comprehensive. This remains true today, but there are new factors to consider, including a promising new contender in the market that’s Odoo. This blog compares Odoo ERP with traditional ERP systems and explains why many companies now see Odoo ERP as the best choice.
What are ERP Systems?
An ERP, or Enterprise Resource Planning, system provides your company with valuable information to help you make better decisions and boost your ROI. You should choose an ERP system based on your company’s specific needs. For instance, if you run a manufacturing or retail business, you will need an ERP system that efficiently manages inventory. A consulting firm, on the other hand, would benefit from an ERP system that enhances daily operations. Similarly, eCommerce stores would select an ERP system tailored to their needs.
Because different businesses have different requirements, ERP system functionalities can vary. Among the various ERP systems available, Odoo ERP is considered one of the best in the ERp market with more than 12 million global users today.
Odoo is an open-source ERP system initially designed for small to medium-sized businesses but now suitable for a wide range of companies. Odoo offers a scalable and configurable point-of-sale management solution and allows you to create customised modules for specific industries. Odoo is gaining more popularity because it is built in a way that allows easy customisation, has a user-friendly interface, and is affordable. Here, you will cover the main differences and get to know why Odoo is gaining attention despite the many other ERP systems available in the market.
The document discusses functions in Python. It introduces functions as a way to divide large programs into smaller, more manageable units called functions. Functions allow code to be reused by calling or invoking the function from different parts of a program. The document then covers key concepts related to functions like arguments, parameters, scope, recursion, and more. It provides examples to illustrate different types of functions and how concepts like scope, recursion, and argument passing work.
Functions allow programmers to organize code into reusable blocks. A function performs a specific task and can accept input parameters and return an output. Functions make code more modular and easier to maintain. Functions are defined with a name, parameters, and body. They can be called from other parts of the code to execute their task. Parameters allow functions to accept input values, while return values allow functions to return output to the calling code. Functions can be called by passing arguments by value or reference. The document provides examples and explanations of different types of functions in C++ like inline functions, functions with default arguments, and global vs local variables.
What's new and changed in PHP 8.
- Major new changes in PHP 8
- New functions and classes
- OOP improvements
- Type system improvements
- Error handling improvements
- Resource to Object migration
- String related changes
- Removed functionality
https://php.watch/versions/8.0
The document introduces functions in C programming. It discusses defining and calling library functions and user-defined functions, passing arguments to functions, returning values from functions, and writing recursive functions. Functions allow breaking programs into modular and reusable units of code. Library functions perform common tasks like input/output and math operations. User-defined functions are created to perform specific tasks. Information is passed between functions via arguments and return values.
PHP is a relatively easy language to learn if you are familiar with HTML/CSS. Here, and following, are the presentations to familiarize yourself with PHP/MySQL and HTML Basics.
A Python module is a file containing Python code such as functions, classes, and variables that can be imported and used in other Python programs. The document discusses several key aspects of Python modules including their structure, importing modules, and built-in modules like the math, random, and statistics modules. The math module contains common mathematical functions, the random module generates random numbers, and the statistics module calculates statistical values like the mean, median, and mode of data sets.
This document discusses functions in C programming. It defines functions as a group of statements that perform a specific task and have a name. Main functions must be included in every C program as it is where program execution begins. Functions help facilitate modular programming by dividing programs into smaller parts. Functions can be user-defined or built-in library functions. Parameters can be passed to functions by value or by reference. Functions can call themselves through recursion. Variables have different storage classes like auto, register, static, and external that determine scope and lifetime.
In this file, MarsDevs illustrates functions in Python, the function argument, and the keyword argument. We use various examples with code to understand the concept better.
Click here to know more: https://www.marsdevs.com/blogs/functions-and-arguments-in-python
This document discusses user-defined functions in C++. It covers value-returning functions, the return statement, function prototypes, and flow of execution. Standard (predefined) functions are discussed as well as advantages of using functions such as modularity, reusability, and the ability to focus on individual parts of a program. Function definitions require a heading specifying return type, name, and parameters, as well as a function body and return statement.
Functions allow for code reusability and modularity by defining reusable blocks of code. A function is defined using the def keyword followed by the function name and parameters. Functions can take in arguments and return values. There are different types of arguments like default arguments, keyword arguments, positional arguments, and arbitrary arguments. Functions improve efficiency and reduce errors through code reuse.
This document discusses user-defined functions in C++. It covers defining functions with return types and parameters, using return statements, function prototypes, and the flow of execution when a function is called. Functions help make programs more modular and understandable by breaking tasks into reusable blocks of code. Defining functions properly allows the compiler to understand how to execute function calls within a program.
This presentation educates you about the Functions of the Python, Defining a Function, Calling a Function, Pass by reference vs value, Pass by reference vs value, Required arguments, Keyword arguments, Default arguments and Variable-length arguments.
For more topics stay tuned with Learnbay.
The document discusses functions in C programming. It defines functions as segments of a program that perform well-defined tasks and can be called independently. Functions make programs modular and easier to write, test and maintain. Key points covered include: functions have a name and signature; parameters are passed between calling and called functions; the return statement ends function execution and returns control/values; parameters can be passed by value or reference.
User Defined Function in C
- Functions modularize programs and allow for code reusability. Parameters allow communication between functions.
- A function definition includes a return type, name, parameters, and block of statements. Functions are called within other functions.
- Functions provide benefits like divide and conquer programming, manageable development, and abstraction that hides internal details.
Python functions allow breaking down code into reusable blocks to perform tasks. There are several types of functions including built-in, user-defined, and anonymous functions. User-defined functions are defined using the def keyword and can take in parameters. Functions can return values using the return statement. Functions are called by their name along with any arguments. Arguments are passed into parameters and can be positional, keyword, or have default values. Functions increase code reuse and readability.
This document discusses PHP functions and how to define, call, and use them. It covers defining functions, arguments and parameters, default argument values, variable scope, and including library files. Functions allow reusable blocks of code and avoid duplicating code. Arguments are values passed into a function, while parameters are variable names used inside the function. Default arguments can be set so functions still work if not all arguments are passed. Variable scope determines where variables can be accessed. Library files allow storing functions in one place and including them elsewhere.
The document discusses various control structures in PHP including functions, variable scope, conditional statements, loops, and include/require statements. Functions allow you to organize your code into reusable blocks. Variable scope determines where a variable can be accessed. Conditional statements like if/else and switch allow executing different code blocks based on conditions. Looping statements like while, do-while, and for repeatedly execute a code block. Include/require is used to include the contents of another file.
This document provides an overview of several advanced Python concepts including generators, iterators, decorators, exceptions handling, SQLAlchemy ORM, and unit testing. Generators allow creating iterators using the yield keyword to pause and resume function execution. Decorators dynamically alter function behavior. Exceptions handling uses try/catch blocks. SQLAlchemy is an ORM for Flask applications. Unit testing ensures code works as expected using libraries like unittest and nose.
The document discusses user-defined functions in C++. It explains that a function allows structuring programs in a modular way by grouping statements that are executed when the function is called. The format of a function includes its return type, name, parameters, and function body enclosed in curly braces. Functions can be called by passing arguments, which are copied to the function's local parameter variables. Functions can return a single value. Function prototypes declare a function's interface without defining its body, allowing a function to be called before it is defined. Arguments can be passed by value, where copies are passed, or by reference, where the function can modify the original variables. Arrays can be passed to functions by only passing the array name
This document discusses different types of functions in C programming. It defines library functions, user-defined functions, and the key elements of functions like prototypes, arguments, parameters, return values. It categorizes functions based on whether they have arguments and return values. The document also explains how functions are called, either by value where changes are not reflected back or by reference where the original values are changed.
When it is all about ERP solutions, companies typically meet their needs with common ERP solutions like SAP, Oracle, and Microsoft Dynamics. These big players have demonstrated that ERP systems can be either simple or highly comprehensive. This remains true today, but there are new factors to consider, including a promising new contender in the market that’s Odoo. This blog compares Odoo ERP with traditional ERP systems and explains why many companies now see Odoo ERP as the best choice.
What are ERP Systems?
An ERP, or Enterprise Resource Planning, system provides your company with valuable information to help you make better decisions and boost your ROI. You should choose an ERP system based on your company’s specific needs. For instance, if you run a manufacturing or retail business, you will need an ERP system that efficiently manages inventory. A consulting firm, on the other hand, would benefit from an ERP system that enhances daily operations. Similarly, eCommerce stores would select an ERP system tailored to their needs.
Because different businesses have different requirements, ERP system functionalities can vary. Among the various ERP systems available, Odoo ERP is considered one of the best in the ERp market with more than 12 million global users today.
Odoo is an open-source ERP system initially designed for small to medium-sized businesses but now suitable for a wide range of companies. Odoo offers a scalable and configurable point-of-sale management solution and allows you to create customised modules for specific industries. Odoo is gaining more popularity because it is built in a way that allows easy customisation, has a user-friendly interface, and is affordable. Here, you will cover the main differences and get to know why Odoo is gaining attention despite the many other ERP systems available in the market.
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemPeter Muessig
Learn about the latest innovations in and around OpenUI5/SAPUI5: UI5 Tooling, UI5 linter, UI5 Web Components, Web Components Integration, UI5 2.x, UI5 GenAI.
Recording:
https://www.youtube.com/live/MSdGLG2zLy8?si=INxBHTqkwHhxV5Ta&t=0
Measures in SQL (SIGMOD 2024, Santiago, Chile)Julian Hyde
SQL has attained widespread adoption, but Business Intelligence tools still use their own higher level languages based upon a multidimensional paradigm. Composable calculations are what is missing from SQL, and we propose a new kind of column, called a measure, that attaches a calculation to a table. Like regular tables, tables with measures are composable and closed when used in queries.
SQL-with-measures has the power, conciseness and reusability of multidimensional languages but retains SQL semantics. Measure invocations can be expanded in place to simple, clear SQL.
To define the evaluation semantics for measures, we introduce context-sensitive expressions (a way to evaluate multidimensional expressions that is consistent with existing SQL semantics), a concept called evaluation context, and several operations for setting and modifying the evaluation context.
A talk at SIGMOD, June 9–15, 2024, Santiago, Chile
Authors: Julian Hyde (Google) and John Fremlin (Google)
https://doi.org/10.1145/3626246.3653374
Transform Your Communication with Cloud-Based IVR SolutionsTheSMSPoint
Discover the power of Cloud-Based IVR Solutions to streamline communication processes. Embrace scalability and cost-efficiency while enhancing customer experiences with features like automated call routing and voice recognition. Accessible from anywhere, these solutions integrate seamlessly with existing systems, providing real-time analytics for continuous improvement. Revolutionize your communication strategy today with Cloud-Based IVR Solutions. Learn more at: https://thesmspoint.com/channel/cloud-telephony
What to do when you have a perfect model for your software but you are constrained by an imperfect business model?
This talk explores the challenges of bringing modelling rigour to the business and strategy levels, and talking to your non-technical counterparts in the process.
SMS API Integration in Saudi Arabia| Best SMS API ServiceYara Milbes
Discover the benefits and implementation of SMS API integration in the UAE and Middle East. This comprehensive guide covers the importance of SMS messaging APIs, the advantages of bulk SMS APIs, and real-world case studies. Learn how CEQUENS, a leader in communication solutions, can help your business enhance customer engagement and streamline operations with innovative CPaaS, reliable SMS APIs, and omnichannel solutions, including WhatsApp Business. Perfect for businesses seeking to optimize their communication strategies in the digital age.
UI5con 2024 - Bring Your Own Design SystemPeter Muessig
How do you combine the OpenUI5/SAPUI5 programming model with a design system that makes its controls available as Web Components? Since OpenUI5/SAPUI5 1.120, the framework supports the integration of any Web Components. This makes it possible, for example, to natively embed own Web Components of your design system which are created with Stencil. The integration embeds the Web Components in a way that they can be used naturally in XMLViews, like with standard UI5 controls, and can be bound with data binding. Learn how you can also make use of the Web Components base class in OpenUI5/SAPUI5 to also integrate your Web Components and get inspired by the solution to generate a custom UI5 library providing the Web Components control wrappers for the native ones.
Flutter is a popular open source, cross-platform framework developed by Google. In this webinar we'll explore Flutter and its architecture, delve into the Flutter Embedder and Flutter’s Dart language, discover how to leverage Flutter for embedded device development, learn about Automotive Grade Linux (AGL) and its consortium and understand the rationale behind AGL's choice of Flutter for next-gen IVI systems. Don’t miss this opportunity to discover whether Flutter is right for your project.
Malibou Pitch Deck For Its €3M Seed Roundsjcobrien
French start-up Malibou raised a €3 million Seed Round to develop its payroll and human resources
management platform for VSEs and SMEs. The financing round was led by investors Breega, Y Combinator, and FCVC.
WWDC 2024 Keynote Review: For CocoaCoders AustinPatrick Weigel
Overview of WWDC 2024 Keynote Address.
Covers: Apple Intelligence, iOS18, macOS Sequoia, iPadOS, watchOS, visionOS, and Apple TV+.
Understandable dialogue on Apple TV+
On-device app controlling AI.
Access to ChatGPT with a guest appearance by Chief Data Thief Sam Altman!
App Locking! iPhone Mirroring! And a Calculator!!
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesQuickdice ERP
Explore the seamless transition to e-invoicing with this comprehensive guide tailored for Saudi Arabian businesses. Navigate the process effortlessly with step-by-step instructions designed to streamline implementation and enhance efficiency.
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
Microservice Teams - How the cloud changes the way we work
WORKING WITH FUNCTIONS
1. WORKING WITH FUNCTIONS
Divide and Conquer
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
2. Introduction
Large programs are often difficult to manage, thus
large programs are divided into smaller units known as
functions.
It is simply a group of statements under any name i.e.
function name and can be invoked (call) from other part
of program.
Take 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 functions for each task to manage
the software development.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
3. Introduction
Set of functions is stored in a file called MODULE.
And this approach is known as MODULARIZATION,
makes program easier to understand, test and
maintain.
Commonly used modules that contain source code
for generic need are called LIBRARIES.
Modules contains set of functions. Functions is of
mainly two types:
Built-in Functions
User-Defined Functions
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
4. Advantages of Function
PROGRAM HANDLING EASIER : only small part of the
program is dealt with at a time.
REDUCED LoC: as with function the common set of code
is written only once and can be called from any part of
program, so it reduces Line of 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 make changes to only one
location.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
5. User Defined Functions
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 USER DEFINED FUNCTION
def function_name([comma separated list of parameters]):
statements….
statements….
KEYWORD FUNCTION DEFINITION
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
6. Points to remember…
Keyword def marks the start of function header
Function name must be unique and follows naming rules
same as for identifiers
Function can take arguments. It is optional
A colon(:) to mark the end of function header
Function can contains one or more statement to perform
specific task
An optional return statement to return a value from the
function.
Function must be called/invoked to execute its code
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
7. User Defined function can be….
1. Function with no arguments and no return
2. Function with arguments but no return value
3. Function with arguments and return value
4. Function with no argument but return value
Let us understand each of the function type with
example….
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
8. Function with no argument and no return
This type of function is also known as void function
FUNCTION NAME NO PARAMETER, HENCE VOID
Return keyword not used
FUNCTION CALLING, IT WILL INVOKE welcome() TO PERFORM ITS ACTION
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
9. Function with parameters but no return value
Parameters are given in the parenthesis separated
by comma.
Values are passed for the parameter at the time of
function calling.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
10. Function with parameters but no return value
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
11. Function with parameter and return
We can return values from function using return
keyword.
The return value must be used at the calling place
by –
Either store it any variable
Use with print()
Use in any expression
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
12. Function with return
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
13. Function with return
NOTE: the return statement ends
a function execution even if it is
in the middle of function.
Anything written below return
statement will become
unreachable code.
def max(x,y):
if x>y:
return x
else:
return y
print(“Iam not reachable”)
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
14. Function not returning value
Function may or may not return a value. Non returning function
is also known as VOID function. It may or may not contain
return. If it contain return statement then it will be in the form
of:
return [no value after return]
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
15. Parameters and Arguments in Function
Parameters are the value(s) provided in the parenthesis
when we write function header. These are the values
required by function to work
If there are more than one parameter, it must be 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 is also known as FORMAL
ARGUMENTS/PARAMETERS
Arguments is also known as ACTUAL
ARGUMENTS/PARAMETER
Note: Function can alter only MUTABLE TYPE values.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
16. Example of Formal/Actual Arguments
ACTUAL ARGUMENT
FORMAL ARGUMENT
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
17. Types of Arguments
There are 4 types of Actual Arguments allowed in
Python:
1. Positional arguments
2. Default arguments
3. Keyword arguments
4. Variable length arguments
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
18. Positional arguments
Are arguments passed to a function in correct
positional order
Here x is passed to a and y is passed to b i.e. in the
order of their position
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
19. If the number of formal argument and actual differs then Python
will raise an error
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
20. Default arguments
Sometimes we can provide default values for our
positional arguments. In this case if we are not
passing any value then default values will be
considered.
Default argument must not followed 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
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
23. 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.
To get control and flexibility over the values sent as
arguments, python offers KEYWORD ARGUMENTS.
This allows to call function with arguments in any
order using name of the arguments.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
25. Rules for combining all three type of arguments
An argument list must first contain positional
arguments followed by keyword arguments
Keyword arguments should be taken from the
required arguments
You cannot specify a value for an argument more
than once
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
26. Example of legal/illegal function call
FUNCTION CALL LEGAL/
ILLEGAL
REASON
Average(n1=20, n2=40,n3=80) LEGAL Non default values provided as
named arguments
Average(n3=10,n2=7,n1=100) LEGAL Keyword argument can be 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
Average(200,num2=90,n3=11) ILLEGAL Undefined argument NUM2
Average(21,num3=900) ILLEGAL A required argument n2 is missing
def Average(n1,n2,n3=100):
return (n1+n2+n3)/3
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
27. Returning Multiple values
Unlike other programming languages, python lets
you return more than one value from function.
The multiple return value must be either stored in
TUPLE or we can UNPACK the received value by
specifying the same number of variables on the left
of assignment of function call.
Let us see an example of both :-
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
28. Multiple return value stored in TUPLE
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
29. Multiple return value stored by
unpacking in multiple variables
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
30. Composition
Refers to using an expression as a part of large
expression, or a statement as a part of large
statement.
Examples
Max((a+b),(c+a)) # Arithmetic
Prize(Card or Cash) # Logical
name="Vikram“
print(name.replace("m","nt").upper()) #function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
31. Scope of Variables
SCOPE means in which part(s) of the program, a
particular piece of code or data is accessible or
known.
In Python there are broadly 2 kinds of Scopes:
Global Scope
Local Scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
32. Global Scope
A name declared in top level segment(__main__) of
a program is said to have global scope and can be
used in entire program.
Variable defined outside all functions are global
variables.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
33. Local Scope
A name declare in a function body is said to have
local scope i.e. it can be used only within this
function and the other block inside the function.
The formal parameters are also having local scope.
Let us understand with example….
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
34. Example – Local and Global Scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
35. Example – Local and Global Scope
„a‟ is not accessible
here because it is
declared in function
area(), so scope is
local to area()
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
36. Example – Local and Global Scope
Variable „ar‟ is accessible in
function showarea() because
it is having Global Scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
37. This declaration “global count” is
necessary for using global
variables in function, other wise an
error “local variable 'count'
referenced before assignment”
will appear because local scope
will create variable “count” and it
will be found unassigned
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
38. Lifetime of Variable
Is the time for which a variable lives in memory. For
Global variables the lifetime is entire program run
i.e. as long as program is executing. For Local
variables lifetime is their function‟s run i.e. as long
as function is executing.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
39. Name Resolution (Scope Resolution)
For every name used within program python follows name resolution rules
known as LEGB 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 it otherwise 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 report the error:
name <variable> not defined
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
40. Predict the output
Program with
variable “value” in
both LOCAL and
GLOBAL SCOPE
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
41. Predict the output
Program with
variable “value” in
both LOCAL and
GLOBAL SCOPE
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
42. Predict the output
Using GLOBAL
variable “value” in
local scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
43. Predict the output
Using GLOBAL
variable “value” in
local scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
44. Predict the output
Variable “value”
neither in local nor
global scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
45. Predict the output
Variable “value”
neither in local nor
global scope
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
46. Predict the output
Variable in Global
not in Local
(input in variable at
global scope)
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
47. Predict the output
Variable in Global
not in Local
(input in variable at
global scope)
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
50. Mutability/Immutability of
Arguments/Parameters and function call
From the previous example we can recall the
concept learned in class XI 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 the memory address of variable.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
51. 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 to myList will be reflected back to List1.
However if we formal argument is assigned to some other variable or data type
then link will break and changes will not reflect back to actual argument
For example (if inside function updateData() we assign myList as:
myList = 20 OR myList = temp
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
52. Passing String to function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
Function can accept string as a parameter
As per Python, string is immutable type, so function
can access the value of string but cannot alter the
string
To modify string, the trick is to take another string
and concatenate the modified value of parameter
string in the newly created string.
Let us see few examples of passing string to
function…
for more updates visit: www.python4csip.com
53. Passing string to function and count how
many vowels in it
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
54. Program to count how many times any
character is present in string
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
55. Program to Jumble the given string by passing
it to function using temporary string
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
56. Passing List to function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
We can also pass List to any function as parameter
Due to the mutable nature of List, function can alter
the list of values in place.
It is mostly used in data structure like sorting, stack,
queue etc.
Let us see how to pass List to function by few
examples:
for more updates visit: www.python4csip.com
57. Passing list to function, and just
double each value
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
58. Passing list to function to double the
odd values and half the even values
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
59. Passing nested list to function and print all those values
which are at diagonal position in the form of matrix
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
60. Passing list to function to calculate sum and average of
all numbers and return it in the form of tuple
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
61. Passing list to function to calculate sum and average of
all numbers and return it in the form of tuple
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
62. Passing tuples to function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
We can also pass tuples to function as parameter
Due to its immutability nature, function can only
access the values of tuples but cannot modify it.
Let us see how to pass tuples in function by few
example…
for more updates visit: www.python4csip.com
63. Input n numbers in tuple and pass it function to count
how many even and odd numbers are entered.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
64. Input n numbers in tuple and pass it function to count
how many even and odd numbers are entered.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
65. Creating a login program with the help of
passing tuple to function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
66. Creating a login program with the help of
passing tuple to function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
OUTPUT OF PREVIOUS PROGRAM
for more updates visit: www.python4csip.com
67. Passing Dictionary to function
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
Python also allows us to pass dictionaries to function
Due to its mutability nature, function can alter the
keys or values of dictionary in place
Let us see few examples of how to pass dictionary
to functions.
for more updates visit: www.python4csip.com
68. Passing dictionary to function with list and stores the
value of list as key and its frequency or no. of
occurrence as value
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
69. Passing dictionary to function with key and value,
and update value at that key in dictionary
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
70. Passing dictionary to function with key and value,
and update value at that key in dictionary
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
71. Understanding of main() function in Python
By default every program starts their execution
from main() function. In Python including a main()
function is not mandatory. It can structure our Python
programs in a logical way that puts the most
important components of the program in one
function.
We can get the name of current module executing
by using built-in variable __name__ (2 underscore
before and after of name)
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
72. Understanding of main() function in Python
We can observe, by default the name of module will be __main__
Most non-python
programmers are having the
habit of writing main()
function where the important
and starter code of programs
are written. In Python we can
also create main() and call it
by checking __name__ to
__main__ and then call any
function, in this case main()
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
73. Recursion
It is one of the most powerful tool in programming
language. It is a process where function calls itself
again and again.
Recursion basically divides the big problem into small
problems up to the point where it can be solved easily,
for example if we have to calculate factorial of a 5, we
will divide factorial of 5 as 5*factorial(4), then
4*factorial(3), then 3*factorial(2), then 2*factorial(1)
and now factorial of 1 can be easily solved without any
calculation, now each pending function will be executed
in reverse order.
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
74. Condition for Implementing Recursion
It must contain BASE CONDITION i.e. at which point recursion will end
otherwise it will become infinite.
BASE CONDITION is specified using „if‟ to specify the termination
condition
Execution in Recursion is in reverse order using STACK. It first divide the
large problem into smaller units and then starts solving from bottom to
top.
It takes more memory as compare to LOOP statement because with
every recursion call memory space is allocated for local variables.
The computer may run out of memory if recursion becomes infinite or
termination condition not specified.
It is less efficient in terms of speed and execution time
Suitable for complex data structure problems like TREE, GRAPH etc
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
75. Example - Recursion
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
76. Example - Recursion
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com
77. Questions based on functions
WAP to create function Lsearch() which takes List
and number to search and return the position of
number in list using Linear Searching method
WAP to create function Bsearch() which takes List
and number to search and return the position of
number in list using Binary Searching method
What is the difference between Local and Global
variables? Also give suitable Python code to
illustrate both
VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &
SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
for more updates visit: www.python4csip.com