Derived from
|
20410560-1 MODULO A - PYTHON programming in Computational Sciences LM-40 GUARINO STEFANO
(syllabus)
The course will cover the following aspects of programming in Python: • An introduction to programming: computer architectures; memory and data; CPU and programs; programming languages; problems, algorithms and programs. • How to use the Python interpreter: invoking the interpreter; argument passing; interactive mode; notebooks; online coding platforms. • Basic concepts of Python programming: variables and assignments; expressions and statements; operations; printing; comments; debbugging; data types; numbers and strings; input. • Functions: built-in functions; function calls; importing modules and functions; math functions; function composition; defining new functions; parameters and arguments; mandatory vs. optional arguments; arguments’ order and keyword assignment; scope of a variable. • Taking decisions: boolean expressions and logical operators; conditional and alternative execution; if-elif-else statements; chained vs. nested conditionals. • Iterations: reassignment and updating variables; the while statement; the break statement; sequences and looping; the in operator; the for loop. • Data structures (strings, lists, tuples, dictionaries): definition, properties, operations and methods; indexing vs. assignment; mutability and immutability; map, filter and reduce; referencing and aliasing; packing and unpacking; lookup and reverse lookup; variable-length arguments. • Files: persistence; opening and closing and the with construct; reading and writing; format operator; filenames and paths; catching exceptions; pickling. • Modules and packages: defining a module; defining a package; importing a package vs. importing a module vs. importing a function; installing packages. • Classes and objects: classes, types, objects and instances; instances as return values; attributes and methods; objects mutability; instantiation and the __init__ method; operator overloading and special methods; static methods and class methods; inheritance. • Pythonic programming: conditional expressions; EAFP (Easier to Ask for Forgiveness than Permission); list comprehension; generator expressions; any and all; sets. • Scientific programming: Numpy, arrays and broadcasting; Pandas, dataframes and series; Scikit-learn and basic machine learning with Python; Matplotlib and plotting in Python
(reference books)
Allen B. Downey, “Think Python: How to Think Like a Computer Scientist (2nd Edition)”, O’Reilly, ISBN-13: 978-1491939369
|