Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Python Program Tutorial at University of the Philippines, Lecture notes of Computer Programming

A tutorial on how to run Python programs. It explains what Python is, its uses, and how to execute Python scripts using different methods. The document also describes the Python interpreter and its role in executing Python scripts. It is a useful guide for beginners who want to learn Python programming.

Typology: Lecture notes

2021/2022

Available from 10/27/2022

tantan-bernabe
tantan-bernabe 🇵🇭

5 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Python Program Tutorial
University of the Philippines
How to run Python Program
What is Python?
Python is an interpreted, general-purpose, high-level programming language that is often used
in system administration and web development.
Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of
Python programming.
Python isn't intended to work in a specific area such as web programming. For this reason, it is
known as a general-purpose programming language that can be used for web, enterprise, 3D
CAD, and more.
Python makes the development and debugging fast because there is no compilation step
included in Python development, and edit-test-debug cycle is very fast.
How to run Python Program?
A Python programmer should know all the ways to run a Python script or code. This is the only
way to check if the code works as intended.
Interpreter is responsible for executing the Python scripts. Python interpreter is a piece of
software which works between the Python program and computer hardware.
Here we are describing the series of ways to run Python scripts.
- The operating system command-line or terminal.
- The Python interactive mode.
- The IDE or Text editor
- The file manager of system.
The operating system command-line or Terminal
The Python shell allows you to run Python code from the command line because any code you
write is lost when you close your session. Therefore, we recommend that you use plain text
files to write your Python code. Text files must be saved with the extension .py. Consider the
following example.
pf3
pf4

Partial preview of the text

Download Python Program Tutorial at University of the Philippines and more Lecture notes Computer Programming in PDF only on Docsity!

Python Program Tutorial University of the Philippines How to run Python Program What is Python? Python is an interpreted, general-purpose, high-level programming language that is often used in system administration and web development. Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming. Python isn't intended to work in a specific area such as web programming. For this reason, it is known as a general-purpose programming language that can be used for web, enterprise, 3D CAD, and more. Python makes the development and debugging fast because there is no compilation step included in Python development, and edit-test-debug cycle is very fast. How to run Python Program? A Python programmer should know all the ways to run a Python script or code. This is the only way to check if the code works as intended. Interpreter is responsible for executing the Python scripts. Python interpreter is a piece of software which works between the Python program and computer hardware. Here we are describing the series of ways to run Python scripts.

  • The operating system command-line or terminal.
  • The Python interactive mode.
  • The IDE or Text editor
  • The file manager of system. The operating system command-line or Terminal The Python shell allows you to run Python code from the command line because any code you write is lost when you close your session. Therefore, we recommend that you use plain text files to write your Python code. Text files must be saved with the extension .py. Consider the following example.

We write the Python print statement and save it as sample.py in working directory. Now, we will run this file using the command-line. Using the Python command line Open a command line and run the Python script. To run the file, you need to enter the file name after python. Now press Enter. If there are no errors in the file, you will see output similar to the following: The Python interactive mode To run Python code, you can use a Python interactive session. You should start an interactive python session. Open a command line or terminal from the start menu, type python and press enter. Here is the example of how to run Python code using interactive shell. print(“Tian Bern”)

Click the green button and you should see the output like this: The file manager system Python files can be run by double-clicking their icon in the file manager. This procedure cannot be used widely during the development phase. This file should be associated with a .py or .pyw file using the python.exe program.