0% found this document useful (0 votes)
3 views15 pages

02 en Python Intro

This document provides an introduction to Python, covering its general-purpose nature, installation process, and development tools. It highlights Python's applications in various fields such as web programming, data analysis, and machine learning. Additionally, it offers resources for further learning and debugging techniques for effective programming.

Uploaded by

s.mariani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views15 pages

02 en Python Intro

This document provides an introduction to Python, covering its general-purpose nature, installation process, and development tools. It highlights Python's applications in various fields such as web programming, data analysis, and machine learning. Additionally, it offers resources for further learning and debugging techniques for effective programming.

Uploaded by

s.mariani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

FONDAMENTI DI PROGRAMMAZIONE (L-Z)

INTRODUCTION TO
PYTHON
INTRODUCTION TO PYTHON 2

OUTLINE
▸ Overview
▸ Installation
▸ Development tools
▸ Further references
OVERVIEW

WHAT IS PYTHON
▸ Python is a general-purpose, interpreted programming language.
▸ general-purpose = suitable for multiple contexts and objectives
▸ interpreted = a special software (virtual machine, runtime) executes Python programs by
interposing between them and the operating system

▸ Python supports both functional and object-oriented programming


▸ Python uses dynamic type checking
▸ duck typing (“if it quacks, it’s a duck”)
▸ ~ variables assume the type of the value they contain at runtime
OVERVIEW

PYTHON FOR MANAGEMENT ENGINEERING


▸ Web programming
▸ Data analysis
▸ Embedded systems programming
▸ Machine learning
▸ ...(could be used for optimization, decision support systems, etc.)
INSTALLATION

DOWNLOADING PYTHON 3
▸ [Link]
▸ Click on the yellow button and scroll down to the "Files" section on the new page
▸ Click the right distribution for your system
▸ For most of you, just click the
yellow button

▸ Otherwise, look for the right


version among the circled
links
INSTALLATION

INSTALLING PYTHON 3
▸ Open the installer you just downloaded to start the installation
▸ Click on the “Install Now” option as shown next to it:
▸ At the end of the installation, verify its success:

Open Windows PowerShell and type py + Enter

In the search bar, look for idle


DEVELOPMENT TOOLS

INTERACTIVE MODE
▸ Open Windows PowerShell (or Command Prompt), type py
and press Enter to enter the interactive mode of the
Python interpreter:

▸ Here you can type Python code to quickly test its functionality.
▸ You can do the same with the IDLE application included with
Python (recommended mode!)
DEVELOPMENT TOOLS

"SCRIPT" MODE
▸ Launch the “IDLE” program
▸ You are in interactive mode, as in the previous slide
▸ Switch to script mode by opening a new file
▸ Write a simple Python program and save it with your preferred name (remember the
save folder)

▸ Run the script (e.g., “[Link]”) by clicking on “Run > Run Module”
DEVELOPMENT TOOLS

DEBUG
▸ Launch the “IDLE” program
▸ Click "Debug > Debugger" on the top bar of the shell
▸ A new window opens: the debugger
▸ Select everything
▸ Use the buttons to execute "step-by-step"
▸ Observe the values of the variables
▸ "Globals" for now
▸ "Locals" later, when we talk about functions and classes
DEVELOPMENT TOOLS

DEBUG
▸ When you run a script (thus in "script" mode), you can forcibly stop its execution to open
the debugger and proceed step-by-step

▸ Right-click on the instruction you want to block


▸ "Set Breakpoint"
▸ Run normally: the execution will
stop right before that instruction,
waiting for your input
(e.g., "Step" button)
DEVELOPMENT TOOLS

PYTHON TUTOR
▸ Web application for visualizing running scripts

▸ Very useful for DEBUGGING, that is, understanding what happens to variables in memory
and during function executions! ([Link]
DEVELOPMENT TOOLS

PYCHARM BY JETBRAINS
▸ Integrated Development Environment (or IDE, from English)
▸ much more powerful than necessary for the course...
▸ ...but much more convenient once you learn the basics
▸ Excellent tutorials and manuals available for beginners,
but in English

▸ I might use it when... I forget not to use it :)


▸ If you want to try it and have questions, contact me for office hours
DEVELOPMENT TOOLS

GOOGLE COLABORATORY (COLAB)


▸ Web development environment
▸ allows you to use Python without downloading or installing it...
▸ ...but requires an internet connection (a server runs your code)
▸ Based on the concept of “notebook”, usable offline (JupyterLab: [Link]
▸ Convenient for sharing code with others
▸ you just need to share the link, or via Google Drive
▸ [Link]
DEVELOPMENT TOOLS

THE PYTHON "ECOSYSTEM"


▸ Developing software is a complex engineering activity
▸ Like all engineering activities, it requires
▸ an appropriate methodology to discipline its phases
▸ suitable tools that maximize productivity
▸ We will not delve deeply into most of these tools...
▸ because the course is not intended to make you professional programmers
▸ because there is not enough time
▸ ...but I might use and mention them in class, so you can find a quick overview on the course's Moodle
site: [Link]
FURTHER REFERENCES

GUIDES, DEEP TAKES, …


▸ As mentioned, Python is a widely adopted language even in professional settings, so it
has excellent documentation

▸ Unofficial documentation (in italian): [Link]


▸ Official tutorial: [Link]
▸ Standard library: [Link]
▸ Programming style: [Link]
▸ None of this is necessary to pass the exam

You might also like