0% found this document useful (0 votes)
26 views

Functions

This document describes various flags that can be used with conversion characters in C/C++ printf and scanf functions. It lists common flags like left justification (-), always show sign (+), add leading zeros (0), and always show decimal (+). It also summarizes the meaning of each flag.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Functions

This document describes various flags that can be used with conversion characters in C/C++ printf and scanf functions. It lists common flags like left justification (-), always show sign (+), add leading zeros (0), and always show decimal (+). It also summarizes the meaning of each flag.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

.1E6 COMMONLY (ISED rconf r'.

ND pri flf CONV F,RSION CI{ARACTITRS IAPP (]

Flags

Flag Meannq

Data itcm is lefi justificd wilhin ftc fi€ld (blank spaccs rcquired to Iill lhc minimum field-
widlh will be sdd€d a/r?r the data ilem ralicr lhan ,y'ore thc dala ilcm.)

A sign (cilhcr + or .) will prcccde.ach siSncd numcrical dala ilcm withoul lhis nag. only
ncgarivc dal, ilcms arc preceded by I sign

0 Causcs leading zcros lo appea, inslcad ofleading bl6nks. Applics only to data hcms that are
ri8hr justificd wilhin a ficld whosc mrnimum size is lar8.r lhrn l.h. data itcm.

(ffote Somc compilers consider thc zcro fla8 to bc a Parl of lhe l].ld'widlh specificalion
rathar thsn an actual oag. This assurcs lhsl lh€ o h proc.sscd last. if muhiplc flags arc
prescni.)

A blmk space will prccadc.ach posilivc siSncd num.rical da(a ilcn. Tlis fla8 rs ovcr-
Alamt tpoce) ridd.n by the + flag ifbolh at prcscnt.

i Causcs oclal nnd hcxadecimal dala ilcms to bc prcc€dcd by 0 alld 0x. respecliv€ly.

Causcs a decimal poinl lo b. pr.senl in all floalinS'point numbc.s. cv.n rflhe data ilem (*r/,
a-,1- and g- is a whole numb.r. Also prclcnls lhe lruncslion oftrailing ?.ros in o-lyp€ convelslon

int a;
short b;
Iong c;
unsigned d;
dooble x;
prlntf ('t+5d t+5hd t+121d t-12Iu t*15,7Ie\n', a, D, c, d, r)i
Appendix H

Library Functions
include Frlc

BbB(i ) int Rctum thc absolutc vrlu. of i. std!ib. h

. acot (d ) doublc Rclun tha crc cosinc ofd. nrti. h

Rctum $e atc sinc ofd. msth.h


Bsin(d) double

.t.n(d) doublc Retum Oc arc tnnS.nt ofd. heth. h

otrn2(d1,d2) doublc Retum lhc src trnSeni of01 /d2. r.th.h


etot ( 6) doublc Convcn suing s lo a doublc_precision qurnlity stdlib, h
etol (s) inl convcn $rint 3 lo an inlcSar. s!dlib. h
atol(s) lonS convcrl slring s ro a lonS inleS€r. stdlib.h
calloc(u1,u2) Allocale mcmory for 6n array having ul fialloc.h, or
elcmcn6" clch oflcnSlh u2 bytcs. Reluma stdlib.h
poinlcr to lhc bcginninS ofthe dlocatcd sp8cc

c!11(d double R.tum a valuc roundcd up lo thc ocxt highcr inlcgcr. oath.h
)

cos (d double Rctum th. cosinc ofd. meth.h


)

cosn (d) doublc Rclum lh. hypcrbolic cosinc ofd. math.h

drtltine(11,12) doubl. Rciuln lhc time differ.nc€ Ll 12. wh€rc -


6nd Il tine. n
I2 r€presenl elapsed tilnes b.yond a d€siSnalcd
bas. timc G€. the tine function).
Clos. all tilcs and bufl. rs, erd lcrminale lhc program. std I ib. h
exit(u)
(V6lue ofu is assjgncd by function, lo indicalr
lcrmination sl,atus.)

erp(d) double Railc e to the power d (p=2.?l82818 is th! basc nath,h


ofihc natural (Napcrian) lyst€m of logarilhms)
febs(d) double Rcrum thc absolutc value ofd. nath.h
tclose (l ) inr Close filc l. Rctum o if fi|. is succ.ssfully closcd. stdi,o.h
taol(t) ini Ddcrrnin€ ifm end-of.filc condilioo ha.s bccn reachcd. 6tdio.h
lfso, tclum a nonzcrc vaiue; olh€twisc, rctum 0.
t0etc (f ) int Enlcr a sinSlc charactcr from fi1. t stdio.h
tgsts(s,1,t) Enl€i slrinS E, conhining l chatactcrs, fiom fi|. t. stdio.h
floor (d) double Rclum . valuc roundcd down lo th. nexl lowcr intcger' nath. n
Reluo thc remaindcrofdl /d2 (wrth sarne sign as d1). nat h, h
tirod(d1,d2) doublc
topon(s1,s2) Opcn a fiI. nsm.d s1 oftypc s2. R.lum r pointcr lo lhc filc. stdlo. h
tprintt(i,... ) inr S€nd data ilcrns |o filc I (remaininS argumenls 3r. stdio,h
cornplicat.d - s€€ Appcndix C).

fputc (c, f ) inl S€nd a sinBl. characi€r to fil€ f. stdio.n


tputs(s,t) int S.nd slring s to tilc t stdio,h

487
488 I,IBRARY FIINCTIONS [APP, H

tuncon lipe
fread(s,i1,i2,t) inl Enlel i2datailems.eachofsize-Ll hyles, from stdlo.h
Itle f lo slring s
lree(p) void Free ablock olallocaled memory whose beginning is malloc,h,or
indicared by p stdlib.h
fscanf(t,...) inl Entar data itcms from file f (remaining argumcnts arc atdio.h
complicrtcd - scc App.ndix C)
fseok(f,l,i) inl Move thc pointcr for fi la f a distancc I byles from stdio.h
localaon i (i ollhc filc,
may rcprcscnt lhc bc8innins
' tha cuncnt poinl€r posilion, or !h€ cod ofthc filc).

ftell(f) long int Rctum lhc currcnl poinlcr posilion within t. fil. stdio.h
lwrite(s,it,i2,f) int Scnd 12 dala alcms. cachofsizc il byles, from stdio h
strin8 s 1o filc 1

getc(t) int Enter a single charactcr from file t.


getcna.( ) inr Ent€r a singlc chamcter fiom lhe slandard inpul d€vice. stdio. h
)
qets (s char' Iintcr strinS s from the nandrrd inpul device stdio.h
isalnum(c) inl Dctemine ifargumenl is alphanumcric Reluma ctvpe.h
nonzero value ifrrue:0 othemisc

lsalpha(c) inl Determine ifargumenl isalphabelic Reluma ctvpe.h


nonzero val!€ illruei O olh€Bise.
rsascrr(c) inl Delermine ifarSument is an ASCIlcharacler. Reluma ctype.h
nonzero value iflruei 0 olherwise
iscntl.l(c) int Delerminc ifargumenl isan ASCII conlrol character ctvpe.h
Rclum a nonzero !alue if(ruei 0 o(hcrwise
rsdrgit(c) int DetermineifargumenlisadecmaldiSrl Reluma ctvpe.h
nonTero Yalue ii true,0 0lhenvisc

rsgrsph(c) r4t l)elermine ifargument Is agraphic ASCIIchr.racler ctvpo.h


(her 0x21-0r7eioclal041 176) Relum a
nonz€ro value iflruei 0 otherwise
rslower(c) inl Delermrne ifargument is lowercase Retum a

non7erc valut ii!ruer o olhemisc


lsodigrt(c) inl Delermine ifarSumenl isanoclaldiSii Reluma ctvpe.h
nonzelo vaiuc iftru€;0 otherwisc
rsprrnt(c) inl Delerminc ifargumenl is aprinling ASCIIcharacler ctvpe.h
(hcx 0x20-017e; oclal 040 176) Relum a nonzero
value if true: 0 oth€r*ise

ispunct(c) inl Delermine ifarSument is a p{rncluation characlcr ctvpe.h


Relum a non/ero value if lruei 0 olhcrwisc

rsspace(c) inl Dctermine rfarSumenl is a whilespacc cha.racter' ctype h

Retum a oonzf,ro valuc iIlruei 0 othen'vise

rsuppgr(c) rnl Dalermlne lfuSumenl is uppercase ctype.h


Relum a nonzcro va,uc iflruel 0 olherwise

rsxdi0it(c) int Delermioc ifalgumcni is a hexade€inaldiSil. ctyPe. h

R€tum a nonrero value iflruci 0 olherwise

labs( 1) inl
lonS Retum lheabsolule valueofL
losld) double Rrrum Ihe naluml lo8arrlhm ofd matn, h
APP, H] LIDRARY FTINCTIONS 489

1o910 (d ) double Rcrum the logadthm (basr t0) ofd. nath.h


nalloc (u ) Allocalc u bytcs ofmemory Relum a pointer
lial]oc, h, or
to lh€ beginninS ofthe allocared space std r ib. h
pow(d1 , d2) double R€lum dt rsiscd to thc d2 power. nath. h
prinrt(. ., ) inr Scnd data itcms to lhc staodard oulput device
stdro.n
(argumcnts arc complicated
pLrtc(c,t)
-
see Appendir c).
inr Scnd a singlc characlcr Io file t. stdio.h
putchar (c) inl Scnd asinglc charactcr to th. stardard outpul dcvice.
stdio. h
puts(s) int Scod string s lo thc standard output d.vicc.
stdio, h
rrnd( ) inr Rctum a random posilive intrgcr.
stdl ib. n
void Mova th. pointcr (o rhc bcginninS o[filc f. stdio.h
scant(,..) int Enrcr data itcms from thc slahdard inpul dcvice
stdio.h
(argumcnls arc complicatcd
- s.c Appcndix G).
3in(d) Rctum $e sine of d.
rath, h
sinn(d) R.lum the hypcrbotic sin€ ofd.
oath, h
sqrr (d) doublc Rctum thc squarc rcot ofd.
mati, h
srand (u ) void Inilializc thc rsndon numbcr g.nerator.
std I ib. h
strcDp(s1,s2) inr Comparc rwo nrinSs l€xicographically. R.tum a
st.ing. n
ncgatjve value ifsl
< s2i O ifst snd s2 arc
idcnlical; ar apositivcvalucifst > s2
strcmpi(s1, s2) inl Compare lwo strings lcxicogrsphica y, wilhout regard
s1rrn0. h
to casa. Rctum s ncgativc valuc ifsl
< s2; O if sj
and s2 are idcntic&l;and a positivc valu. i[s I > rA.
strcpy (sl ,62) char. Copy shng s2 to string st st ri ng. h
strlen(5) int Rctum thc numbcr of characlcas in a string. st.ing, h
str56t (s, c) Scr all characlcrs within s lo c (cxcludioa lh. string. h
tcrminaling null chars.lcr \O).
syst6n(s ) iot Pass command s ro lhe opcrarinS system
stdlib.h
Rctum ifthc command is succcssfull, cxccuicdi
O
olh.rwisr, rclum a nonz.ro valu., typjcally _t
tan(d ) double Rclu.n lhc tangcot ofr,.
math.tl
tanh(d) doublc Rcllm thc hyperbolic langent ofd.
fiath, h
t i'ne (p ) lon8 inl Rcrum fie numbcr gfscconds clapscd
t ime. h
bcyood a dcsignated basc limc
toascll (c) ,ni Convcrt valuc ofargumcot to ASCII.
tol,ower(c) inl Convcrt lefl€r (o lowercase.
ctype. h, or
stdtib. h
toupP€r(c) Convcd lcncr to upp.rcasc.
s tdlib. h

Noler: TWe rcfe.s@ tJrc daE rypc oftlc quanliry $st is retum.d by thc functioo An aslcrisl (.) denotes a pornte,
c dcnotcs a charactcr.typ. argumcnt
d denotcs a doublc.prectsion argumcnl
Python has a set of
Burt in Functions

Functlon Description
abs0 Returns the absolute value of a number
aul) Returns True if all itemslnan terable object aretrue

?-0J0
Returns True if any item n an ilerable object istrue
ascio Returns a readable vers on oF an oblect. Rep aces none_ascil characters wrth escape

Returns the binary version of a number


hinll
boo!0 Returns thc boolean va ue of thc speot ed oblect

by,teErGvll Returns an array of bytes


bytes0 Returns a bytes object
c!ll?ble0 Returns True if the specifled object is ca lable, otherw se False
qh.rl) Returns a character from the specrf ed llnicode code.
classmethodo Converts a method into a c ass method
cgmp,ilell Returns the specifred source as an oblect, ready to be executed
comolex0 Returns a comP ex nurnber
delatll0 De etes the specified atlribute (property or method) from the spec f ed object
disl) Returns a dictionary (ArraY)
dtll Returns a list of the specifed object's properties and methods
divmod0 Returns the quotient and the remainder when argumentl s divided by argument2
enumerate0 Takes a co lection (e q. a iup e) and returns rt as an enumeraie object
Evaluates and executes an expression
cvall]
ex9cl) Executes the specified code (or obiect)

f!Lte Use a f lter funct on to exclude tems in an iterab e object


float() Returns a floaling Po nt number

lcroa!11 Formats a spec fied value


fro2enselll Returns a frozenset obiect
Returns the value of ihe specifred attr bute (properiy or method)
ce!ctg)
clo.E!!) Returns the current global symbo table as a dlctronary
hasattr{} Returns True if the specifed obiect has the specified attribute (propedy/rnethod)
hash0 Returns the hash value of a specifed object
helpo Executes the built-in helP sYstem

he!{l Converts a number nto a hexadecimal value


id0 Returns the id of an object
rllpqtll A lowrng uscr nplt
i!,tLl Returns an integer number
isinsta!ce0 Returns TrLre f a soec fted oblect ls an nstance of a specifred obiect

15!qb3?!{) Returns True if a spec fied c ass is a subclass of a speclfied object


iter0 Returns an iterator object
lerr0 Returns the length of an oblect
list()
!ssde0 RetLrrns an updated d ctionary of the current local symbol lable

!naBl) Returns the specified terator with the specified function appled to each rtem
max() Returns the largest item in an terable
mel]lgrf{icrv-0 RetLrrns a memory view object
min{) Returns the smallest iterr in an iterable
0er Returns the next item n an iterab e
obiect{) Returns a new object
oc Converts a nurnber into an octal
ope!0 Opens a file and returns a fle obiect
ordl) Convert an nleger representlng the unicode of the spec Fied character
Returns the value of x !o the power of y
ry" onnic r^ rhp <t:n.lar.l ortort d.vr.c
properiy0 Gets, sets, deletes a property
range0 Returns a sequence of numbers, starling from 0 and increments by 1 (by default)
rcp() Returns a readable version of an object
reversed{) Rcturns a reversed terator
round0 Rounds a nlmbers
sel0 tlctlrfs d ncw sct object
setattr0 Seis an attrlbute (propertv/rnethod) ofan obiect
sllceo Reiurns a slce ob]ect
sorted0 Returns a sorted list
stnt cnrethod0 Converts a method into a slat c method
nro Retlrns a str ng object
sumo Sums the items of an iterator
5!per0 Returns an obiecl that represents the parent class
tuple0 Returns a tuple
rype Returns lhe rype ol a'r oblecl
vars() Retlrns the dict . properiy of an object
lipo Returns an iterator, from two or more terators
pylhon has a scl of buill in methods that you can use on strinSs.
Notei All slring nrethods retLrns new values They do not change the oriSinal string.
Method Description
fapita!11C0 Converts the irrst character to upper case
casefold0 Converts string nto lower case
.^1to'l) perJ.'rs a ce_le-ed s ring

.ount0 Returns the number of times a speciFied value occurs in a string


cncode0 Returns an encoded version of the string
endswith0 Returns true ri lhe strinq ends wrth the speclfied value
elp4Od!ab{} Sets the tab size of the strlng
f nd{) Searches the string for a specified value and returns the position of whe.e it was found
format0 Formats specified values in a strrng
lormat mapO Fornats specrfied values in a string
indox0 Searches ihe slring For a specified value and returns the positron of where lt was found
isalnum0 Rcturns True rf. characters rn the strrng arc alphanumerrc
isalpha0 Returns True if a characters rn lhe sirrng are rn the alphabet
igascii0 Returns True f al characters n the str ng are ascll characters
isdecimal0 Rel!rns True rf all characters n the string are decimals
isdlglt0 Returns True rr all characters rn the string are d gits
rsidentlfier0 Returns True if the str ng rs an deniifier
isower0 ReturnsTrue fal characters n the strlng are lower case
Returns True if all characters in the string are numeric
'SIIVrlqflo Returns True if all characters in the string are printable
isprintablei)
lsspace0 Returns True if all characters in lhe string are whitespaces
istitle0 Returns True if the string follows the rules of a title
rsupper0 Returns True if all characters in the string are Llppei case

io n0 Converts the elements of an terable rnto a str ng


ltus!0 Returns a left llstifed versron of the string
lower0 Converts a strrng nto lower case
str pl) Retllrns a left tr m versron of the stnng
nlaketrans0 RctLrrns a translatron tableto be !rsed in translalions
partition0 Returns a tuple where the stnng is parted rnto three parts
repiaceO Returns a strng wherc a spccired vdlue rs replaced wrth a specfed v. Lre
rfind() Searches the str ng for a specified value and relurns the last posltion 6f where it was
iound
Python TLrp e Methods
Method DescriPtion
counto Returns the number of tlmes a specified value occurs in a tuple
ind-6x0 Scarches the tuple for a spec fied value and returns the posit on of where t was found

Python Set Methods


Method oescription
add0 Adds an element to the set
. ear0 Removes al the e ements f rom the set
copy0 Returns a coPY of the set
(l ffu,rcrrcc() Rcturns a set contdrn ng ihe drffercnce betwcen two or more sets
dfferenceUpdate()RemovestheltemsnlhlssetthatarealsoincUdedinanother,specfiedset
dlscard0 Remove lhe specrfed tem
intersecJion0 Returns a set, thai is the ntersection of iwo or more sets
lntersection update0 Removestheitems nthissetthatarenotpresentinother'specrfedset(s)
isdisioint{) Returns whether two sets have a intersection or not
issubset0 Return' whether another set contains this set or not
issuperset0 Returnq whether thrs set contains another set o' not
pop0 Removes an element from the set
removeo Removes the spec fied e ement
symmetric difference0 Rcturns a set l^' th the symmeiric differences of two sets
!vmmelric difference update0 nserts lhe symmetric differences From th s set and another
un ono Rcturn a set contarning the unron o[ sets
rpdate0 Update lhe set w th another set, or any other iterable

Python Fi e Methods
Method DescriPtion
close0 Closes the file
dctach0 Returns the separated raw stream from the buffer
fi enol) Returns a number that represents the stream, from the operating svstem's
perspectlve
flush0 llushes the nternal buffer
isattv0 Returns whether the file stream rs interact ve or not
read0 Returns the frle conient
rcadable0 Returns whether the file stream can be read or not
re.dl nc0 ll.Lurns onc rne from lhe frlc
rerdl nes{) rleilrrnsalsiof nesfromthef le

5cck0 Chanqc thc fr c Pos tron


seekable0 Returns whether lhe file a ows us to change the f le posrtion
tell0 Returns lhe current fr e positron
trun.ate0 Resizes the file to a specified srze
writablel) Returns whether the file can be wrrtten to or not
write0 Wales the specified string to the file
writel neso Wntes a I st of str ngs lo the f le
nndex0 Searches the strrng lora specified va ue and returns the ast posit on of wherc it was
found
rjust0 Returns a right iustified vers on of the string
rpartition0 Returns a tuple where the string s parted nto three parts
rsplit0 spltsthe string atthespecFied separator, and relurns a ist
rstrip0 Returns a rlght lrim vers on of the string
split0 Splrtsthe string atthe spec fied separator, and returns a rst
splitlines0 Spl ts the stnng at line breaks and returns a lrst

startswith0 Returns true if the string starts w th the specif ed vaiue


strip() Returns a trrrnmed versron of the str ng
swapc€ge(l swaps cases, lower case becomes upper case and vice versa
title0 Converts the first character of each word to upper case
t@!51 !e.0 Returns a translated string
uppe(i converts a str ng into upper case
zfill0 Fills the string with a specifi€d number of 0 values at the beginninq

Python List/Array N.4ethods

Method DescriPtion
Aplelldo Adds an element at the end of the list
cleaO Removes a I the elarnents from the I st
coPY() Returns a coPY of the list
counto Returns the number of clcment! wrth thc specrfrcd va ue
extend0 Add the elements of a list (or any iierab e), to lhe end ot the current
lst
index0 Returns the index of the f rst e ement l^'rth the speof ed value
inslftIl Adds an element at the specifled position
pop0 Removes the elemenl at the specifred position
remQveo Removes the first iiem with the spec fied value
reverse0 Reverses the order of the list
s!(11 Sorts the llst

Python Dictlonary Methods


Method DescriPtion

clear0 Removes all the elements from the dictionary

copv0 RetLrrns a copy of the dictionary

ffSfnl''e.y,s0 Returns a dictionary with the specified keys and value

set0 Returns the value of the specified key

items{} Returns a list containing a tuple for each key value pair

lef.so Returns a list containing the dictionary's keys

pop0 Removes the elernent wth the specifled key

popltem0 Removes the last inserted key valuc pair

setdefaUlt()ReturnstheVa|ueofthespecfedkey,Ifthekeydoesnolexlst:nsertthekey,vr'thth..
sPecified value
update0 Updates the dictionary wth the spccificd kcy value pairs

value50 Returns a iist of all the values in the dictionary


math.acos0 Returns the arc cosine of a number
math.acosh0 Retu.ns the inverse hyperbo ic cosine of a number
math.asino Returns the arc sine of a number
math.asinh0 Returns the nverse hyperbolicsne ofa number
math.atan0 Returns the arc tangent of a number in radians
math.atan20 Returns the arc tangent of y/x in radians
math.?1anhll Returns the inverse hyperbolic tangent of a number
math.ceilo Rounds a number up to the nearest integer
math.combo Returns lhe number of ways to choose k items from n items without repetition and order
math.copys gno Returns a f oat cons sting of the va ue of the first parameter and the sign of the second parameter

math.cos0 Retlrns the cosine of a number


fath.co!h0 rlcturns thc hypcrboi c cos ne of a nLmber
math.deereeso Converts an angie lrom rad ans to deqrees
math distl) Relurns the Eucldcan drstance between two pornts (p and q), where p and q are the coord nates o
that pornt
math.erf0 Returns the error function of a number
nath erfc0 Returns the complementary error funchon of a number
math.exp0 Returns E raised to the power of x
math expm1o Returns E" - 1

math.fabsl) Returns the absolute value of a number


math.factorial0 Returns the factorlal of a nurnber
math.floori) Rounds a number down to the nearest integer
math.fmod0 Returns the remainder of x/y
math.frexpo Returns the mantissa and the exponent, of a specified number
math fsum0 Returns the sum of all riems in any rterable (tuples, arrays, lists, etc.)
math gamma0 Returns the gamma funct on al x
math.gcd0 Ret!rns thc grcatest common drvsoroftwo ntegers
math.hypot{) RetLrrns the Euclidean norrr1
math.isclose0 Checks whether two values are close to each other, or not
math isfinite0 Checks whether a number is finite or not
malh.isinf() Checks whether a number s rnfinrte or not
malh.isnan0 Checks whether a value ls NaN (not a nurrber) or not
math isqrt0 llounds a square root number downwards to the nearest rnteger
math.ldexp0 Bet!ro! ltc lrr-lelrra-lrlath.frexpi) whiqb islll2]lllOllhssivclllrllllqrlGrdr
math.lgammao Returns the og gamma value of x
math.log0 Returns the natural logarithm of a number, or the logarithm of nlrmber to base
malh.log100 Returns the base'10 logaathm of x
math.loglp0 Returns the natura logarithm of 1+x
math. oB20 Returns the base ogarrthm of r
2
math.perm0 Returns the number of ways to choose k terns from n rtems with orderand wiihout repetrt on
math pow0 Rcturns the valuc of x to the power ot v
math prod0 Returns the product of all the elements in an iterable
math.radians0 Converts a degree value rnto radians
rnath,remaindeO Returns the closest value that can make numerator completely divrsible by the denorninator
malh sin0 Rcturns the s ne of a number
math.sinh0 Returns the hyperbolc srne of a number
math.sqrt0 Returns thc sqlare root of a number
fna![la!0 Returns the tangent of a number
math.tanh0 Returns the hyperbolic tangent of a number
- rnath.trunc0 Returns the truncated integer parts of a number

ir/tlron cmath Mod(r e

Method Description
cmath.acos(x) Returns the arc cos ne value of x
.math a.nshlxl Returns the hvoerbolc arc cos ne ol x
Python Random Modu e
Method DescriPtion
!eed0 Init a ize the random number generator
getstate0 Returns the current nlernal state ofthe random nurnber generator
setstate0 Restores the lnternal state of the random number generator
getrandbits0 Returns a number representrng the random b ts
randrange0 Returns a random numbel" beillieen the g ven range
randint0 Returns a randorn number between the qrven range
choicgl] Returns a random element from the qiven sequence
choices0 Returns a list with a random se ect on from the qiven sequen'e

lhrlJtlel-l Takes a sequence and returns the sequence in a random order


sample0 Returns a g ven sample oF a sequence
random0 Returns a random float number between 0 and 1

uniforrn0 Returns a random float nurnber betwcen two given pararneters


Returnsarandomfloatnumberbet!'\']eentwogivenpararneters'youcanalsosetarnode
parameter to spec fy the rn dpoint between the two other paramcters
(used in
betavariate0 Returns a random float number between O and 1 based on the Beta dlstnbution
statistics)
expovariate0 Returns; random float number based on the Exponential distrlbution (used in statistics)
gammavariateo Returns a random float number based on the Gamma distribution (used in statistics)
9auss0 ReturnsarandomfloatnumberbasedontheGaussiandistribution(usedinprobabilitytheories)
lognormvariateo RetUrnsarandomfloatnumberbasedonalognormaIdistributon(usedinprobabilltytheories)
normalvariate0 Returnsarandomfloatnumberbasedonthenormaldistribution(usedinprobab]litytheories)
vonmisesvariate0 Returns a random float number based on the von Iqises distribution (used in directional
stat st cs)
paretovarate()ReturnsarandomfloatnumberbasedontheParetodistr]bution(usedinprobabitytheones)
weibulvariate()ReturnsarandomfloatnUmberbasedontheweibu]ldistribution(usednstatlstics)

Python Requests Module


Method Description
delete(url, args) Sends a DELETE request to the spec fied url
get(url, params, args) Sends a GET request to the specrfred ur
head(url,arAs) Sends a HEAD request to the specif ed lrl
patchlurt, data, args) Sends a PATCH rcqucst to the spec |cd url

pos(url, data, ison, args) Sends a POST request lo the speclFied url
wl(url, data, arqs) Sends a PUT r€quest to the spcc fred ur
rcquesllmethod, url, args) Sends a request of the speciiied method to the spec fied url

Python statlstics Module


Method DescriPtion

statrstics.harmqnic rnean0 Ca culates the harmonic mean (central locatron) of the g ven data
statistiCs.ILeqt!-{) Calculates the mean (averaqe) of the given data
Calculates the median (middle value) of the given data
$a!$!!5.!Ediaa{)
the median of grouped continuous data
stat istics. redia nl(quPed.ll Calculates
Calc!lates the high median of the given data
$4!nie9.!oediao-bicl'11
statistics.median-low0 calculates the low median of the qiven data

statisti!s.ngde1) Calculates the mode (central tendency) of the given numeric or nominal data
statistics.PgtdevIl calculates the standard deviation from an entlrc populatlon
statistic!.stdev0 Calculates the standard deviation from a sample of data
s!a.!istiq.Pv.a-!!!qe0 Calculates the variance of an entire population
5tatistics.variance{) Calculates the variance from a sample of data

Python math Module


Method Description
cmath.asin(x) Returns the arc sine of x
cmath.asinh(x) Returns the hyperbolrc arc s ne oi x
cmath.ltan(x) Returns the arc tangent value of x
cmath atanh(x) Returns the hyperbolic arctangent vaiue of x
cmath.cos(x) Returns the cosrne oi x
cmath cosh(x) Returns the hyperbo rc cosine of x
cmath.exp()) Pervrns the va ue of Er, where E is Futer,s nurnber (approximatety 2.718281. .), and x rs the
,-\rrx\htn "r t6'1t
cmath.isclose0 / Checks whethcr two valLt,-'s arc closc, or nor
cmath.isfinite(x) Checks whether x s a fin te number
cmath.isinf(x) Check whelher x ls a posrt vc or neqat ve rntrnty
cmath.isnan(x) Checks whelher x rs NaN (not a numbeo
cmath.iog(x[, base]) Returns the logarithm of x to the base
cmath.laglolxl Returns the base-1o logarithm of x
cmath.phaseo Return the phase of a complex number
cmath.pola(l Convert a complex number to potar coordrnates
cmath.rect0 Convert po ar coordinates to rectangular form
cmath linld Returns the sine of x
cmath.sinhlx) Returns the hyperbo] c sine of x
cmath.sqrt(x) Returns the square root of x
cmath tan(x) Relurns the tangent of x
cmath tanh(x) Returns the hyperbolc tanqent of x

You might also like