Prévia do material em texto
<p>Pointal 4 Python 3 Cheat Sheet on Base Types ordered sequences access values Container Types int 783 0 -192 list [1,5,9] float 9.23 0.0 tuple (1,5,9) bool True False str str bytes of . key containers access each key unique dictionary dict byte set for Identifiers int 15 type Conversions by 63 specify number in allowed should be avoided int (15.56) 15 decimal part language float 1124000000 0 PPER case discrimination round rounding decimal decimal integer max bool (x) False for x empty container x None False x True for other and for str (x) of for display formuming on back) Variables assignment (64) code representation with string right side list 2+8+ (y) 3: 'three') set - 'one two 2 6. str and of a,b=b, pawd 12 pawd *b=seq & list of str *a b=seq with spaces split() spaces str str list of str x-=2 x-None sequence of one type list of another type list del [int for in 29 [1,29, -3] for Sequence Containers Indexing negative -4 -2 -2 Items count Individual access to items 1st [index] (1st) 1st 1st= [10 20 30 40 50 0 1 2 3 4 : from -3 -1 from (list) with -2 and with assignment Access sequences 1st and 1st 1st 1st 1st 1st 1st 1st indication - (list) del 1st [3:5] 1st Boolear Logic Blocks true FY Modules Names Imports Comparisons statement from import as as a and b logical and import and packages aya a or b logical other Statement and and or condition that and if logical condition : statement not a logical not statements block True True and constates Can one the of if condition Maths from pt. Priority sin 707 if bool not raise - log processing try floor (12 except as . order of operations a finally processing block as Loop Statement for each Loop Statement condition of whi le logical Loop Control for var in statements block break statements block continue before Go sequence's values with before the while managed by for if print print print x y+4) Display items display Go sequence's index print options item index around end of 18 pein standard for input Inst ruct ions ) Input if of input always to required type boxed Conversion on the other 15 lost) (c) count Generic Operations on Containers Go over sequence's index and values sun (c) For sorted (c) list for val in val in in not in range and Integer Sequences (c) included True all range range 10 True at least of the False range has of c count function (identifier) Function Definition import copy copy of def fet copy deepcopy deep copy ion modify list Operations on Lists statements etc. add end return res the computed add result return all be and the 1st with value think box 1st pop remove 1st sort 1st .reverse place diet) Operation on Dictionaries Sets d.clear (3,1+2,2*1) Function Call del per function for which does the copy d.popitem() Operations on Strings - strip . and Files open (" file txt lower for operations encode Formatting "nodele( fornat str writing reading write read f Selection 72793) list close the Formatting flush D seek with octal opening with with as and for line string percent #</p>