Pyhton Functions
Pyhton Functions
Sub:- ICT
2. Presenters Name:-
Khushi jain(IU2141230067)
Aagam buttani(IU2141230019)
3. Class:- CSE-3(Sem 3)
4. Program:- B-TECH
5. Topic Name:- Python functions
Khushi jai
Introduction to Python:-
1. What is Python?
Python is an interpreted, object-oriented, high-level programming
language with dynamic semantics . It was originally released in 1991.
Designed to be easy as well as fun, the name "Python" is a nod to the
British comedy group Monty Python.
2. Uses of Python:-
3. What are the benefits of
Python?
4. Features of Python:-
Python Funtions:-
Output:-
Enter a number: 2.4
Enter another number: 6.5
The sum is 8.9
(ii)Built-in Functions :-
The Python interpreter has a number of functions that are
always available for use. These functions are called built-in
functions. For example, print() function prints the given
object to the standard output device (screen) or to the text
stream file.
In Python 3.6, there are 68 built-in functions. But for the sake
of simplicity let us consider the majorly used functions and we
can build on from there.
Syntax:-
The syntax of abs() method is:-
abs(num)
Example:-
1# random integer
2integer = -20
3print('Absolute value of -20 is:', abs(integer))
4
5#random floating number
6floating = -30.33
7print('Absolute value of -30.33 is:', abs(floating))
Output:-
Absolute value of -20 is: 20 Absolute value of -30.33
is: 30.33
Python all() Function:-
Definition:-
The all() method returns True when all
elements in the given iterable are true. If not, it
returns False.
Syntax:-
The syntax of all() method is:
all(iterable)
Example:-
1# all values true
2l = [1, 3, 4, 5]
3print(all(l))
4
5# all values false
6l = [0, False]
7print(all(l))
8
9# one false value
10l = [1, 3, 4, 0]
11print(all(l))
12
13# one true value
14l = [0, False, 5]
15print(all(l))
16
17# empty iterable
18l = []
19print(all(l))
Output:-
True
False
False
False
True
(iii) Python Lambda Functions:-
Output:-
10
In [1]:
(iv)Python Recursive Functions:-