上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Something You Should Know Computational Thinking and Approach
Something You Should Know Computational Thinking and Approach
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY ntroduction 。Program paradigms -Imperative,functional,declarative,object-oriented ·Python Multi-paradimed Interpreter:.py is translated (not compiled)to byte code,and then is execute on Virtual machine of Python Software development process
Introduction • Program paradigms – Imperative, functional, declarative, object-oriented • Python – Multi-paradimed – Interpreter: .py is translated (not compiled) to byte code, and then is execute on Virtual machine of Python • Software development process
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY ntroduction Three key elements of Computer Science Design,Analysis,experimentation Two key elements of to develop a solution to a problem Data structure and Algorithm 。Modular programing 。Algorithm analysis Time and Space Big-O notation
Introduction • Three key elements of Computer Science – Design, Analysis, experimentation • Two key elements of to develop a solution to a problem – Data structure and Algorithm • Modular programing • Algorithm analysis – Time and Space – Big-O notation
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY BUILT-IN TYPE AND EXPRESSIONS
BUILT-IN TYPE AND EXPRESSIONS
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Object,variable and type Object is everywhere in Python Variable is a label that you could stick to any object Object has a type,variables do not have it The type of the object referred by 'toto' Mutable and immutable objects >>type('Hello,World!) Int,float,string,tuple >>>type(17) -List,dictionary,others... >>type(1.02)
Object, variable and type • Object is everywhere in Python • Variable is a label that you could stick to any object • Object has a type, variables do not have it – The type of the object referred by ‘toto’ • Mutable and immutable objects – Int, float, string, tuple – List, dictionary, others… >>> type('Hello, World!') >>> type(17) >>> type(1.02)
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Names (identifier) 。Rule: Every identifier must begin with a letter or underscore (")followed by any sequence of letters,digits,or underscores. ·Reserved word Words used in controls:if,else,try... -Words used to specify:global,class Types are not reserved word list,float
Names (identifier) • Rule: – Every identifier must begin with a letter or underscore (“_”), followed by any sequence of letters, digits, or underscores. • Reserved word – Words used in controls: if, else, try… – Words used to specify: global, class • Types are not reserved word – list, float…
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Order of the execution Operations Low Operator Description (from lowest precedences to highest precedences lambda Lambda expression or Boolean OR and Boolean AND not x Boolean NOT 1n,not1n,18,1snot,,>=,◇,1=,= Comparisons,including membership tests and identity tests, Bitwise OR A Bitwise XOR Bitwise AND > Shifts Addition and subtraction *,1,/1,8 Multiplication,division,remainder +X-X ~X Positive,negative,bitwise NOT ★女 Exponentiation x[index],x[index:index],x(arguments...),x.attribute Subscription,slicing,call,attribute reference High (expressions...),[expressions...],(key:datum...},expressions... Binding or tuple display,list display,dictionary display,string conversion
Order of the execution Operations Low High
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Operation Basic operation on different type objects ·Type of the results: -bool->Int->double->float.... -20/7&20.0/7 Never trust =with float Application on mutable and immutable object: -a=(1,2) a=[1,2] -b=(3,4) b=[3,4] a+=b,a=a+b a+=b,a=a+b
Operation • Basic operation on different type objects • Type of the results: – bool->Int->double->float…. – 20/7 & 20.0/7 • Never trust == with float • Application on mutable and immutable object: – a=(1,2) – b=(3,4) – a+=b, a=a+b a=[1,2] b=[3,4] a+=b, a=a+b
上降充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Very important objects 。 String File object ·List Mutable!!!! Dictionary All functions associated with: -append,remove,len,index [][][5],[:4],slicing,negative index
Very important objects • String • File object • List – Mutable!!!! • Dictionary • All functions associated with: – append, remove, len, index – [], [:],[:5], [::4], slicing, negative index
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY String Formatting 。Format%value %. ·%s,%d,%f,%10.5f >>>"compare号10fand号0.20f"号(3.14,3.14) 10
String Formatting • Format % value • %. • %s, %d, %f, %10.5f >>> “compare %10f and %0.20f” % (3.14, 3.14) 10