20410560-1 - MODULE A - PYTHON programming

Acquire the ability to implement high-level programs in the interpreted language Python. Understand the main constructs used in Python and its application to scientific computing and data processing scenarios.

Curriculum

teacher profile | teaching materials

Mutuazione: 20410560-1 MODULO A - PROGRAMMAZIONE IN PYTHON in Scienze Computazionali LM-40 GUARINO STEFANO

Programme

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

Core Documentation

Allen B. Downey, “Think Python: How to Think Like a Computer Scientist (2nd Edition)”, O’Reilly, ISBN-13: 978-1491939369

Attendance

Attendance to the course is not mandatory, but in case of 2 or more absences on Monday students will be required to take an oral exam, which is otherwise optional.

Type of evaluation

Each week, starting with the second, the Monday class will be devoted to a session of exercises to be handed in at the end of the class and which will be graded for a maximum of 3.5 points per session, or 21 total points. At the end of the course, students will have to take a multiple-choice quiz for a maximum of 10 points. Finally, an oral test will be scheduled for non-attending students or for those who have not turned in their exercises on time. The oral will instead be optional for the other students.

teacher profile | teaching materials

Mutuazione: 20410560-1 MODULO A - PROGRAMMAZIONE IN PYTHON in Scienze Computazionali LM-40 GUARINO STEFANO

Programme

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

Core Documentation

Allen B. Downey, “Think Python: How to Think Like a Computer Scientist (2nd Edition)”, O’Reilly, ISBN-13: 978-1491939369

Attendance

Attendance to the course is not mandatory, but in case of 2 or more absences on Monday students will be required to take an oral exam, which is otherwise optional.

Type of evaluation

Each week, starting with the second, the Monday class will be devoted to a session of exercises to be handed in at the end of the class and which will be graded for a maximum of 3.5 points per session, or 21 total points. At the end of the course, students will have to take a multiple-choice quiz for a maximum of 10 points. Finally, an oral test will be scheduled for non-attending students or for those who have not turned in their exercises on time. The oral will instead be optional for the other students.