SlideShare a Scribd company logo
2
Most read
6
Most read
13
Most read
FUNCTIONS IN PYTHON
CLASS: XII
COMPUTER SCIENCE(083)
INTRODUCTION
A function is a block of organized, reusable code that is used to perform
a single, related action.
What are Functions?
Functions are a convenient way to divide your code into useful blocks,
allowing us to order our code, make it more readable, reuse it and save
some time. Also functions are a key way to define interfaces so
programmers can share their code.
A Function in Python is used to utilize the code in more than one place
in a program. It is also called method or procedures.
Why we need functions?
We can easily work with problems whose solutions can be written in the
form of small python programs.
Like Example: To Accept the name and display it.
nm=input(“enter the name”)
print(“your name=“,nm)
As the problems become more complex, then the program size and
complexity and it become very difficult for you to keep track of the data
and know each and every line.
So python provides the feature to divide a large program into different smaller
modules or functions. These have the responsibility to work upon data for
processing. Example:
statements
statements
statements
statements
statements
statements
statements
statements
statements
.
.
.
statements
This
program is
one long,
complex
sequences
of
statements
If we are using
the functions
the task divided
into smaller
tasks, each task
perform his
work and all
these task are
combined when
need according
to requirements
Function1:
statements
statements
statements
statements
Function2:
statements
statements
statements
statements
Function3:
statements
statements
statements
statements
Task 1:
Task 2:
Task 3:
TYPES OF FUNCTIONS
There are three types of functions categories:
Built-in functions:
Modules:
User define Functions:
Built-In Functions
The Python built-in functions are predefined functions that are already
available in python. It makes programming more easier, faster and more
powerful. These are always available in the standard library.
Type conversion functions:
It provide functions that convert values from one type to another.
str() :
float() :
eval() :
int() :
int() : Convert any value into an integer.
Example:
If we want to accept two numbers A, B from user and using input() and
you know that input return string, so we need to convert it to number
using int()
A=int(input(“Enter value for A”))
B=int(input(“Enter value for B”))
s=A+B
print(“sum=“,s)
--------OUTPUT---------
Enter value of A 20
Enter value of B 30
sum=50
A=input(“Enter value for A”)
B=input(“Enter value for B”)
s=A+B
print(“sum=“,s)
--------OUTPUT---------
Enter value of A 20
Enter value of B 30
sum=2030
It concatenate means
joining of characters
str() : Convert any value into an string.
Example:
If we want to convert number 25 into a string, so we need to use str()
A=25
print(“A=“,A)
--------OUTPUT---------
A=25
A=25
print(“A=“,str(A))
--------OUTPUT---------
A=’25’
float() : Convert any value into an string.
Example:
If we want to convert number 25 into a floating value, so we need to use
float()
A=float(25)
print(“A=“,A)
--------OUTPUT---------
A=25.0
If we convert a string value into
float
A=float(‘45.895’)
print(“A=“,A)
--------OUTPUT---------
A=45.895
eval() : It is used to evaluate the value of string. It takes value as string
and evaluates it into integer or float
A=eval(‘45+10’)
print(“A=“,A)
--------OUTPUT---------
A=55
If we accept value in integer or float it
should automatically evaluate by the
function for that we use eval().
A=eval(input(“enter the value”))
print(“A=“,A)
If we enter value in number it convert
it automatically into number
--------OUTPUT---------
Enter the value 45
A=45
If we enter value in number it convert
it automatically into number
--------OUTPUT---------
Enter the value 45.78
A=45.78
abs() : It return absolute value of a single number. It takes an integer or
floating value and always return positive value.
A=abs(-45)
print(“A=“,A)
--------OUTPUT---------
A=45
A=abs(-45.85)
print(“A=“,A)
--------OUTPUT---------
A=45.85
pow(x,y) : function returns the value of x to the power of y (xy)
A=pow(2,3)
print(“A=“,A)
--------OUTPUT---------
A=8
type() : If you wish to find the type of a variable,
A=10
B=9.23
C=‘That’
N=[1,2,3]
M=(20,30)
D={‘rollno’:101,’name’:’rohit’}
print(type(A))
print(type(B))
print(type(C))
print(type(N))
print(type(M))
print(type(D))
-------OUTPUT----------
<class 'int'>
<class 'float'>
<class 'str'>
<class 'list'>
<class 'tuple'>
<class 'dict'>
round() : It is used to get the result up to a specified number of digits.
print(round(10))
print(round(10.8))
print(round(6.3))
-----Output-----
10
11
6
The round() method takes two argument
• The number to be rounded and
• Up to how many decimal places
If the number after the decimal place given
• >=5 than + 1 will be added to the final value
• <5 than the final value will return as it is
print(round(10.535,0))
print(round(10.535,1))
pprint(round(10.535,2))
-----Output-----
11.0
10.5
10.54
Modules
A file containing functions and variables defined in separate files. A
module is simply a file that contain python code in the form of separate
functions with special task. The module file extension is same .py . To use
it, you must import the math module:
We discuss one module file:
Inside this Math module there are many functions of math's
ceil()
floor()
pow(x,y) sqrt(value)
cos(value)sin(value) tan(value)
Which includes trigonometric functions, representation functions,
logarithmic functions, etc.
Math.py
Math.pi
ceil()
floor() It rounds a number downwards to its nearest integer
It rounds a number upwards to its nearest integer.
import math
x = math.ceil(1.4)
print(x)
-----OUTPUT-----
2
import math
x = math.floor(1.4)
print(x)
-----OUTPUT-----
1
import math
x = math.ceil(-1.4)
print(x)
-----OUTPUT-----
-1
import math
x = math.floor(-1.4)
print(x)
-----OUTPUT-----
-2
pow(x,y)
This method returns the power of the x corresponding to the
value of y. In other words, pow(2,4) is equivalent to 2**4.
import math
number = math.pow(2,4)
print("The power of number:",number)
-------OUTPUT------
The power of number: 16
number = 2**4
print("The power of number:",number)
-------OUTPUT------
The power of number: 16
sqrt(value) It returns the square root of a given number.
import math
print(math.sqrt(100))
----OUTPUT----
10.0
import math
print(math.sqrt(3))
----OUTPUT----
1.7320508075688772
Math.pi
It is a well-known mathematical constant and defined as the ratio of
circumstance to the diameter of a circle. Its value is 3.141592653589793.
import math
print(math.pi)
------OUTPUT------
3.141592653589793
cos(value)sin(value) tan(value)
Trigonometric functions
This function
returns the sine of
value passed as
argument. The
value passed in this
function should be
in radians.
This function returns
the cosine of value
passed as argument.
The value passed in
this function should
be in radians.
This function returns the
tangent of value passed as
argument. The value
passed in this function
should be in radians.

More Related Content

PPTX
Operator Overloading In Python
Simplilearn
 
PDF
Python Collections Tutorial | Edureka
Edureka!
 
PDF
Stack
Zaid Shabbir
 
PPT
Python Dictionaries and Sets
Nicole Ryan
 
PPTX
Stack and its applications
Ahsan Mansiv
 
PPTX
Python for loop
Aishwarya Deshmukh
 
PPT
Searching in c language
CHANDAN KUMAR
 
PPTX
Looping Statements and Control Statements in Python
PriyankaC44
 
Operator Overloading In Python
Simplilearn
 
Python Collections Tutorial | Edureka
Edureka!
 
Python Dictionaries and Sets
Nicole Ryan
 
Stack and its applications
Ahsan Mansiv
 
Python for loop
Aishwarya Deshmukh
 
Searching in c language
CHANDAN KUMAR
 
Looping Statements and Control Statements in Python
PriyankaC44
 

What's hot (20)

PPTX
Call by value or call by reference in C++
Sachin Yadav
 
PDF
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
PPTX
greedy algorithm Fractional Knapsack
Md. Musfiqur Rahman Foysal
 
PPTX
Infix to postfix conversion
Then Murugeshwari
 
PPTX
Functions in Python
Kamal Acharya
 
PPTX
Python Data Structures and Algorithms.pptx
ShreyasLawand
 
PPT
Data structures using c
Prof. Dr. K. Adisesha
 
PPTX
Error and exception in python
junnubabu
 
PPTX
Method overloading
Lovely Professional University
 
PPTX
Packages In Python Tutorial
Simplilearn
 
PPT
Algebraic structures
BindhuBhargaviTalasi
 
PPT
Binary search tree in data structures
chauhankapil
 
PPT
Introduction to Python
amiable_indian
 
PPTX
Python: Modules and Packages
Damian T. Gordon
 
PPTX
Built in function
MD. Rayhanul Islam Sayket
 
PPTX
queue & its applications
somendra kumar
 
PPTX
Functions in Python
Shakti Singh Rathore
 
Call by value or call by reference in C++
Sachin Yadav
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
greedy algorithm Fractional Knapsack
Md. Musfiqur Rahman Foysal
 
Infix to postfix conversion
Then Murugeshwari
 
Functions in Python
Kamal Acharya
 
Python Data Structures and Algorithms.pptx
ShreyasLawand
 
Data structures using c
Prof. Dr. K. Adisesha
 
Error and exception in python
junnubabu
 
Method overloading
Lovely Professional University
 
Packages In Python Tutorial
Simplilearn
 
Algebraic structures
BindhuBhargaviTalasi
 
Binary search tree in data structures
chauhankapil
 
Introduction to Python
amiable_indian
 
Python: Modules and Packages
Damian T. Gordon
 
Built in function
MD. Rayhanul Islam Sayket
 
queue & its applications
somendra kumar
 
Functions in Python
Shakti Singh Rathore
 
Ad

Similar to INTRODUCTION TO FUNCTIONS IN PYTHON (20)

DOCX
Functions.docx
VandanaGoyal21
 
PDF
ch 2. Python module
Prof .Pragati Khade
 
PDF
Advanced Web Technology ass.pdf
simenehanmut
 
PPTX
Python Lecture 4
Inzamam Baig
 
PPTX
Input statement- output statement concept.pptx
SindhuVelmukull
 
PPTX
The Input Statement in Core Python .pptx
Kavitha713564
 
PPTX
Unit 2function in python.pptx
vishnupriyapm4
 
ODP
James Jesus Bermas on Crash Course on Python
CP-Union
 
PDF
python modules1522.pdf
DebanjanMaity13
 
PDF
Pres_python_talakhoury_26_09_2023.pdf
RamziFeghali
 
PPTX
Unit2 input output
deepak kumbhar
 
PDF
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
PPTX
Unit 2function in python.pptx
vishnupriyapm4
 
PDF
Python-02| Input, Output & Import
Mohd Sajjad
 
PPTX
CHAPTER 01 FUNCTION in python class 12th.pptx
PreeTVithule1
 
PDF
Functions_19_20.pdf
paijitk
 
PDF
Functions_in_Python.pdf text CBSE class 12
JAYASURYANSHUPEDDAPA
 
PPTX
Introduction to Python Programming – Part I.pptx
shakkarikondas
 
PPTX
CLASS-11 & 12 ICT PPT Functions in Python.pptx
seccoordpal
 
PPTX
Functions_in_Python.pptx
krushnaraj1
 
Functions.docx
VandanaGoyal21
 
ch 2. Python module
Prof .Pragati Khade
 
Advanced Web Technology ass.pdf
simenehanmut
 
Python Lecture 4
Inzamam Baig
 
Input statement- output statement concept.pptx
SindhuVelmukull
 
The Input Statement in Core Python .pptx
Kavitha713564
 
Unit 2function in python.pptx
vishnupriyapm4
 
James Jesus Bermas on Crash Course on Python
CP-Union
 
python modules1522.pdf
DebanjanMaity13
 
Pres_python_talakhoury_26_09_2023.pdf
RamziFeghali
 
Unit2 input output
deepak kumbhar
 
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
Unit 2function in python.pptx
vishnupriyapm4
 
Python-02| Input, Output & Import
Mohd Sajjad
 
CHAPTER 01 FUNCTION in python class 12th.pptx
PreeTVithule1
 
Functions_19_20.pdf
paijitk
 
Functions_in_Python.pdf text CBSE class 12
JAYASURYANSHUPEDDAPA
 
Introduction to Python Programming – Part I.pptx
shakkarikondas
 
CLASS-11 & 12 ICT PPT Functions in Python.pptx
seccoordpal
 
Functions_in_Python.pptx
krushnaraj1
 
Ad

More from vikram mahendra (20)

PPTX
Communication skill
vikram mahendra
 
PDF
Python Project On Cosmetic Shop system
vikram mahendra
 
PDF
Python Project on Computer Shop
vikram mahendra
 
PDF
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
PDF
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
PPTX
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
PPTX
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
PPTX
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
PPTX
OPERATOR IN PYTHON-PART1
vikram mahendra
 
PPTX
OPERATOR IN PYTHON-PART2
vikram mahendra
 
PPTX
USE OF PRINT IN PYTHON PART 2
vikram mahendra
 
PPTX
DATA TYPE IN PYTHON
vikram mahendra
 
PPTX
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
vikram mahendra
 
PPTX
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
PPTX
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
PPTX
Python Introduction
vikram mahendra
 
PPTX
GREEN SKILL[PART-2]
vikram mahendra
 
PPTX
GREEN SKILLS[PART-1]
vikram mahendra
 
PPTX
Dictionary in python
vikram mahendra
 
PPTX
Entrepreneurial skills
vikram mahendra
 
Communication skill
vikram mahendra
 
Python Project On Cosmetic Shop system
vikram mahendra
 
Python Project on Computer Shop
vikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
OPERATOR IN PYTHON-PART1
vikram mahendra
 
OPERATOR IN PYTHON-PART2
vikram mahendra
 
USE OF PRINT IN PYTHON PART 2
vikram mahendra
 
DATA TYPE IN PYTHON
vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
Python Introduction
vikram mahendra
 
GREEN SKILL[PART-2]
vikram mahendra
 
GREEN SKILLS[PART-1]
vikram mahendra
 
Dictionary in python
vikram mahendra
 
Entrepreneurial skills
vikram mahendra
 

Recently uploaded (20)

PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PDF
5.EXPLORING-FORCES-Detailed-Notes.pdf/8TH CLASS SCIENCE CURIOSITY
Sandeep Swamy
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PDF
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Landforms and landscapes data surprise preview
jpinnuck
 
5.EXPLORING-FORCES-Detailed-Notes.pdf/8TH CLASS SCIENCE CURIOSITY
Sandeep Swamy
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 

INTRODUCTION TO FUNCTIONS IN PYTHON

  • 1. FUNCTIONS IN PYTHON CLASS: XII COMPUTER SCIENCE(083) INTRODUCTION
  • 2. A function is a block of organized, reusable code that is used to perform a single, related action. What are Functions? Functions are a convenient way to divide your code into useful blocks, allowing us to order our code, make it more readable, reuse it and save some time. Also functions are a key way to define interfaces so programmers can share their code. A Function in Python is used to utilize the code in more than one place in a program. It is also called method or procedures.
  • 3. Why we need functions? We can easily work with problems whose solutions can be written in the form of small python programs. Like Example: To Accept the name and display it. nm=input(“enter the name”) print(“your name=“,nm) As the problems become more complex, then the program size and complexity and it become very difficult for you to keep track of the data and know each and every line.
  • 4. So python provides the feature to divide a large program into different smaller modules or functions. These have the responsibility to work upon data for processing. Example: statements statements statements statements statements statements statements statements statements . . . statements This program is one long, complex sequences of statements If we are using the functions the task divided into smaller tasks, each task perform his work and all these task are combined when need according to requirements Function1: statements statements statements statements Function2: statements statements statements statements Function3: statements statements statements statements Task 1: Task 2: Task 3:
  • 5. TYPES OF FUNCTIONS There are three types of functions categories: Built-in functions: Modules: User define Functions:
  • 6. Built-In Functions The Python built-in functions are predefined functions that are already available in python. It makes programming more easier, faster and more powerful. These are always available in the standard library. Type conversion functions: It provide functions that convert values from one type to another. str() : float() : eval() : int() :
  • 7. int() : Convert any value into an integer. Example: If we want to accept two numbers A, B from user and using input() and you know that input return string, so we need to convert it to number using int() A=int(input(“Enter value for A”)) B=int(input(“Enter value for B”)) s=A+B print(“sum=“,s) --------OUTPUT--------- Enter value of A 20 Enter value of B 30 sum=50 A=input(“Enter value for A”) B=input(“Enter value for B”) s=A+B print(“sum=“,s) --------OUTPUT--------- Enter value of A 20 Enter value of B 30 sum=2030 It concatenate means joining of characters
  • 8. str() : Convert any value into an string. Example: If we want to convert number 25 into a string, so we need to use str() A=25 print(“A=“,A) --------OUTPUT--------- A=25 A=25 print(“A=“,str(A)) --------OUTPUT--------- A=’25’
  • 9. float() : Convert any value into an string. Example: If we want to convert number 25 into a floating value, so we need to use float() A=float(25) print(“A=“,A) --------OUTPUT--------- A=25.0 If we convert a string value into float A=float(‘45.895’) print(“A=“,A) --------OUTPUT--------- A=45.895
  • 10. eval() : It is used to evaluate the value of string. It takes value as string and evaluates it into integer or float A=eval(‘45+10’) print(“A=“,A) --------OUTPUT--------- A=55 If we accept value in integer or float it should automatically evaluate by the function for that we use eval(). A=eval(input(“enter the value”)) print(“A=“,A) If we enter value in number it convert it automatically into number --------OUTPUT--------- Enter the value 45 A=45 If we enter value in number it convert it automatically into number --------OUTPUT--------- Enter the value 45.78 A=45.78
  • 11. abs() : It return absolute value of a single number. It takes an integer or floating value and always return positive value. A=abs(-45) print(“A=“,A) --------OUTPUT--------- A=45 A=abs(-45.85) print(“A=“,A) --------OUTPUT--------- A=45.85 pow(x,y) : function returns the value of x to the power of y (xy) A=pow(2,3) print(“A=“,A) --------OUTPUT--------- A=8
  • 12. type() : If you wish to find the type of a variable, A=10 B=9.23 C=‘That’ N=[1,2,3] M=(20,30) D={‘rollno’:101,’name’:’rohit’} print(type(A)) print(type(B)) print(type(C)) print(type(N)) print(type(M)) print(type(D)) -------OUTPUT---------- <class 'int'> <class 'float'> <class 'str'> <class 'list'> <class 'tuple'> <class 'dict'>
  • 13. round() : It is used to get the result up to a specified number of digits. print(round(10)) print(round(10.8)) print(round(6.3)) -----Output----- 10 11 6 The round() method takes two argument • The number to be rounded and • Up to how many decimal places If the number after the decimal place given • >=5 than + 1 will be added to the final value • <5 than the final value will return as it is print(round(10.535,0)) print(round(10.535,1)) pprint(round(10.535,2)) -----Output----- 11.0 10.5 10.54
  • 14. Modules A file containing functions and variables defined in separate files. A module is simply a file that contain python code in the form of separate functions with special task. The module file extension is same .py . To use it, you must import the math module:
  • 15. We discuss one module file: Inside this Math module there are many functions of math's ceil() floor() pow(x,y) sqrt(value) cos(value)sin(value) tan(value) Which includes trigonometric functions, representation functions, logarithmic functions, etc. Math.py Math.pi
  • 16. ceil() floor() It rounds a number downwards to its nearest integer It rounds a number upwards to its nearest integer. import math x = math.ceil(1.4) print(x) -----OUTPUT----- 2 import math x = math.floor(1.4) print(x) -----OUTPUT----- 1 import math x = math.ceil(-1.4) print(x) -----OUTPUT----- -1 import math x = math.floor(-1.4) print(x) -----OUTPUT----- -2
  • 17. pow(x,y) This method returns the power of the x corresponding to the value of y. In other words, pow(2,4) is equivalent to 2**4. import math number = math.pow(2,4) print("The power of number:",number) -------OUTPUT------ The power of number: 16 number = 2**4 print("The power of number:",number) -------OUTPUT------ The power of number: 16
  • 18. sqrt(value) It returns the square root of a given number. import math print(math.sqrt(100)) ----OUTPUT---- 10.0 import math print(math.sqrt(3)) ----OUTPUT---- 1.7320508075688772 Math.pi It is a well-known mathematical constant and defined as the ratio of circumstance to the diameter of a circle. Its value is 3.141592653589793. import math print(math.pi) ------OUTPUT------ 3.141592653589793
  • 19. cos(value)sin(value) tan(value) Trigonometric functions This function returns the sine of value passed as argument. The value passed in this function should be in radians. This function returns the cosine of value passed as argument. The value passed in this function should be in radians. This function returns the tangent of value passed as argument. The value passed in this function should be in radians.