0% found this document useful (0 votes)
11 views3 pages

Built-In Functions

12th built in function

Uploaded by

sangeethajeya4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Built-In Functions

12th built in function

Uploaded by

sangeethajeya4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Built-in Functions Group 1 Group 2

Chapter 7 Functions Recall ac for pbit(9) cfs(3)


Total Functions - 12 in 2 groups Recall
Goup 1 General Functions 9 ac for pbit
Group 2 import math Mathematical Functions 3 cfs

Goup 1 General Functions ac for pbit - 9


Sl Name Syntax Example
returns the absolute
1 abs() abs(x) value of x x=-20 print(abs(x))=>20
retuns the unicode
character for the given x=65
2 chr() chr(i) ASCII print(chr(x))=>A

format(value [, returns the output as x=3 print(format(x,


3 format() format_spec]) per the given format 'b'))=>11

retuns the ASCII for x='A'


4 ord() ord(c) the given unicode print(ord(c))=>65
round(number, retuns the nearest x=3.6
5 round() [,ndigits]) integer print(round(x))=>4

a,b=2,3
6 pow() pow(a,b) returns a power b print(pow(a,b))=>8
returns binary string x=3
7 bin() bin(i) prefixed with 0b print(bin(x))=>'0b11'
returns the identify of x=3
8 id() id(object) an object print(id(x))=>address of x
returns the type of x=3
9 type() type(object) object print(id(x))=>address of x

Group 2 Mathematical Functions import math cfs -3


retuns the smallest x=3.6
10 ceil() math.ceil(x) integer >=x print(math.ceil(x))=>4
retuns the largest x=3.6
11 floor() math.floor(x) integer <=x print(math.floor(x))=>3
returns the square import math
12 sqrt() math.sqrt(x) root of x print(math.sqrt(x))
Group 1 Group 2 Group 3
Chapter 8 - String Functions Recall lcfc(4) laadu(5) clust(5)
Total Functions - 14 in 3 groups
Goup 1 string functions 4 lcfc
Group 2 import math is() functions 5 laadu
Group 3 5 clust
Group 1(4) Recall string functions lcfc
returns the length of str='hello'
1 len() len(str) the string print(len(str))=>5
cout(str, [beg, returns the number of str='hello welcome'
2 count() end]) substrings in str print(str.count('el'))=>2
finds the first
find (sub [, start occurrence of sub str='hello welcome'
3 find() [,end]]) string in str print(str.find('el'))=>1
str='hello'
center(width, print(str.center(6, "*")=>
4 center() fillchar) returns centered string hello*

Group 2- Recall is() functions laadu Note - No parameter


all functions as str.
returns True if string is str='hello'
5 islower() islower() lowercase print(str.islower()=> True
returns True if string is str='hello'
6 isalpha() isalpha() an alphabet print(str.islower()=> True
returns True if string is str='hello'
7 isalnum() isalnum() alpha numeric print(str.islower()=> False
returns True if string str='hello'
8 isdigit() isalnum() has only numbers print(str.isdigit()=> False
returns True if string in str='hello'
9 isupper() isupper() uppercase print(str.isupper()=> False
Group 3- Recall string functions clust Note - No parameter
Capitalize first str='hello'
10 capitalize() capitalize() character of string print(str.isupper()=> Hello
returns lowercase of str='HELLO'
11 lower() lower() string print(str.lower()=> hello
returns uppercase of str='hello'
12 upper() upper() string print(str.upper()=> HELLO
str='hello'
change the case of print(str.swapcase()=> HELLO
13 swapcase() swapcase() every character
str='hello welcome'
returns string in title print(str.swapcase()=> Hello
14 title() title() case Welcome
Chapter 9 - Collection Data Types Group 1 Group 2
icc (3) cfs(3)

Total Functions - 8 in 2 groups Recall


Goup 1 List functions - accepts parameter 5 ic mms
Group 2 aggregate List functions - No parameter 3 csr

Goup 1 List functions Parameterized functions ic mms - 5


Sl Name Syntax Example

list.index returns the index value l=[1,2,3,2]


1 index() (element) of first occurrence l.index(2)=>1
returns the number of l=[1,2,3,2]
2 count() list.count(value) similar elements l.count(2)=>2

accepts list as parameter


returns the minimum list=[1,4,3,2]
3 min() min(list) value min(list)=>1
returns the maximum list=[1,4,3,2]
4 max() max(list) value max(list)=>4
list=[1,4,3,2]
5 sum() sum(list) returns the sum sum(list)=>10

Group 2 non-parameterized list functions


retuns the unicode
6 copy() list.copy() character for the given l=[1,2,3,2] d=l.copy()

sort()-affects sorts list argument l=[2,1] l.sort()=>[1,2]


7 original list list.sort() reverse=True optional l.sort(reverse=True)->[2,1]
l=[1,2,3,2]
8 reverse() list.reverse() reverses the list l.reverse()=>[2,3,2,1]

Chapter 7 12
Chapter 8 14
Chapter 9 8
34

You might also like