run python code in ubuntu terminal

Download this code from
Title: Running Python Code in Ubuntu Terminal – A Step-by-Step Tutorial
Python is a versatile programming language, and running Python code from the Ubuntu terminal is a common practice for developers and system administrators. In this tutorial, we’ll guide you through the process of executing Python scripts in the Ubuntu terminal, covering the basics and providing practical examples.
Before we begin, make sure you have the following:
Getting Started:
Open the Terminal:
Create a Python Script:
Use your favorite text editor to create a simple Python script. For example, you can use nano:
In the editor, type the following Python code:
Save the file (Ctrl + X, then Y to confirm, and Enter).
Navigate to the Script Location:
Run the Python Script:
Execute the Python script using the python3 command:
or, if your script is executable:
You should see the output Hello, Ubuntu! printed to the terminal.
Understanding Command Line Arguments:
Using Command Line Arguments:
Run the Script with an Argument:
Execute the script with a command line argument:
You will see the output Hello, YourName!.
Congratulations! You’ve successfully run Python code in the Ubuntu terminal. This tutorial covered creating a simple script, navigating the terminal, and executing Python code. Feel free to explore more advanced topics, such as virtual environments and package management, as you continue your journey with Python on Ubuntu.


Leave a Reply

Your email address will not be published. Required fields are marked *