3.0 University logo
  • Home
  • About us
  • All Courses
    • Cybersecurity Programs
      • Certified Ethical Hacker (CEH v13)
      • Certified SOC Analyst
      • Certified Penitration Testing Professional
      • Computer Hacking Forensic Investigator
      • Certified Cybersecurity Technician (CCT)
      • Certified AI Program Manager
      • Certified Offensive AI Security Professional
      • Certified Responsible AI Governance & Ethics Professional
      • Artificial Intelligence Essentials
    • Crypto Market Programs
    • Blockchain & Web3 Programs
      • Digital Assets Trading & Analysis Program
      • Certified Web3 Strategy & Growth Specialist
      • Certified Web3 Governance & Compliance Expert
      • Full Stack Blockchain Developer Program
      • Private Blockchain Developer Program
      • Public Blockchain Developer Program
    • IGM x IIG Programs
      • Jewellery Design Executive Program
      • Gems & Diamond Specialist Program
      • Jewellery Business Specialist Program
  • Schools
    • School of Decentralized Economics
    • School of Cyber Resilience
    • School of Intelligent Systems
    • School of Design Thinking
  • Partners
    • Certification & Knowledge Partner
    • Academic Partner
    • Hiring Partner
    • Delivery Partner
    • Affiliate Partner
    • Hybrid Center Partner
  • Blog
  • Home
  • About us
  • All Courses
    • Cybersecurity Programs
      • Certified Ethical Hacker (CEH v13)
      • Certified SOC Analyst
      • Certified Penitration Testing Professional
      • Computer Hacking Forensic Investigator
      • Certified Cybersecurity Technician (CCT)
      • Certified AI Program Manager
      • Certified Offensive AI Security Professional
      • Certified Responsible AI Governance & Ethics Professional
      • Artificial Intelligence Essentials
    • Crypto Market Programs
    • Blockchain & Web3 Programs
      • Digital Assets Trading & Analysis Program
      • Certified Web3 Strategy & Growth Specialist
      • Certified Web3 Governance & Compliance Expert
      • Full Stack Blockchain Developer Program
      • Private Blockchain Developer Program
      • Public Blockchain Developer Program
    • IGM x IIG Programs
      • Jewellery Design Executive Program
      • Gems & Diamond Specialist Program
      • Jewellery Business Specialist Program
  • Schools
    • School of Decentralized Economics
    • School of Cyber Resilience
    • School of Intelligent Systems
    • School of Design Thinking
  • Partners
    • Certification & Knowledge Partner
    • Academic Partner
    • Hiring Partner
    • Delivery Partner
    • Affiliate Partner
    • Hybrid Center Partner
  • Blog
    Login
    ₹0.00 0 Cart

    Learn Articles

    • Home
    • Learn Articles

    How to Write and Run a Python Program (Beginner Guide)

    • Posted by 3.0 University
    • Date August 16, 2026
    • Comments 0 comment

    To run a Python program, install Python from python.org, save your code in a .py file, then type python script.py (Windows) or python3 script.py (Mac/Linux) in your terminal. First-time setup takes under ten minutes.

    1. Download and install Python from python.org.
    2. Write your code and save the file as hello.py.
    3. Open your terminal or Command Prompt.
    4. Navigate to the file folder using the cd command.
    5. Run python hello.py (Windows) or python3 hello.py (Mac/Linux).
    • Key Takeaway 1: Always tick “Add Python to PATH” during Windows installation or your terminal won’t find the python command.
    • Key Takeaway 2: On Ubuntu and macOS, use python3, not python, to avoid hitting the legacy Python 2 interpreter.
    • Key Takeaway 3: A good text editor or IDE (VS Code, PyCharm) makes writing and running Python programs far less painful than Notepad.
    • Key Takeaway 4: Virtual environments keep your projects clean and prevent dependency conflicts from day one.
    • Key Takeaway 5: Python is genuinely beginner-friendly, but expect a realistic four to six weeks before you feel comfortable writing scripts on your own.

    Install Python and Check the Version

    Head to python.org/downloads and grab the latest stable release. As of mid-2025, that is Python 3.13. The download page auto-detects your OS, so you will usually land on the right installer immediately.

    Windows Installation

    Run the installer and, before you click anything else, check the box that says “Add Python to PATH”. This single checkbox is the reason most beginners spend an hour searching for “python is not recognized as an internal or external command.” Check it, then click Install Now.

    Once it finishes, open Command Prompt and type:

    python –version

    You should see something like Python 3.13.0. If you see an error, the PATH environment variable was not set. You can fix it manually through System Environment Variables, or just re-run the installer with that checkbox ticked.

    macOS and Ubuntu Installation

    macOS ships with Python 2.7 in older versions and sometimes a stub in newer ones. Do not rely on it. Install Python 3 via the official installer or Homebrew (brew install python3), then verify with:

    python3 –version

    On Ubuntu, Python 3 is usually pre-installed. Run python3 –version to confirm. If it is missing or outdated, run sudo apt update && sudo apt install python3 and you are done in seconds.

    Operating System Correct Command to Run a Python Program Common Installer Source PATH Setup Needed?
    Windows 10/11 python script.py python.org installer Yes (tick checkbox)
    macOS (Monterey+) python3 script.py python.org or Homebrew Usually automatic
    Ubuntu 22.04 / 24.04 python3 script.py apt package manager No
    Any OS (inside VS Code) Run button or F5 Python extension for VS Code Auto-detected

    Write and Run Your First Python Program

    Open any text editor, type the following line, and save the file as hello.py:

    print(“Hello, World!”)

    Open your terminal, change into the folder where you saved the file using the cd command, and run it. On Windows: python hello.py. On Mac or Linux: python3 hello.py. The terminal prints Hello, World! and drops back to the prompt. That is it. You just ran your first Python program.

    How to Run a Python Script from the Command Line Using an IDE

    VS Code is free, lightweight, and used by millions of developers globally. Install the official Python extension from Microsoft, open your .py file, and hit F5 to run it. You get syntax highlighting, autocomplete, and inline error hints without any complex setup.

    PyCharm Community Edition is another solid choice, especially if you are building larger projects. It is free, handles virtual environments automatically, and is popular among Python developers at Indian IT companies like Infosys, Wipro, and TCS who use Python for automation and data pipelines.

    Setting Up a Virtual Environment

    Before you install any third-party packages, create a virtual environment. This keeps your project dependencies isolated from your system Python interpreter. Run:

    python3 -m venv myenv

    Activate it on Mac/Linux with source myenv/bin/activate and on Windows with myenv\Scripts\activate. Your terminal prompt changes to show the environment name. Now any package you install with pip install packagename stays inside that folder and does not interfere with other projects.

    According to the Stack Overflow Developer Survey 2024, Python is the most popular programming language for the third consecutive year, with 51% of developers reporting they use it. That is partly because the learning curve is genuinely shallow compared to languages like C++ or Java.

    How to Run a Python Program on Ubuntu, Mac, and Inside an IDE

    Running a Python program from the terminal is the most transferable skill you can build early. Whether you are on a Linux server, a Mac at home, or a Windows machine at your office, the mental model is the same: write the file, point the interpreter at it, and execute the script.

    How to Run a Python Script on Ubuntu Step by Step

    Ubuntu is the dominant Linux distribution in Indian engineering colleges and cloud servers alike. Once Python 3 is installed, running a script is straightforward. Open a terminal and type:

    python3 /path/to/script.py

    If you want to make a script executable directly without typing python3 every time, add a shebang line as the very first line of your file:

    #!/usr/bin/env python3

    Then make it executable with chmod +x script.py and run it as ./script.py. This is standard practice in Linux automation and shell scripting workflows.

    Is Python Easy to Learn for Beginners?

    Honestly, yes, compared to most other programming languages. Python syntax reads almost like plain English, there is no semicolon at the end of every line, and you do not need to declare variable types. A motivated beginner can write useful scripts within a week.

    That said, easy to start does not mean easy to master. Expect your first month to feel productive but also frustrating when you hit indentation errors, import issues, or confusing error tracebacks. That is normal. According to the TIOBE Index (June 2025), Python holds the number one position in programming language popularity, which means the community, tutorials, and Stack Overflow answers available to beginners are enormous.

    For Indian learners specifically, Python opens doors to data science, AI, web development, and cybersecurity roles. According to NASSCOM’s Future of Tech 2024 report, Python is one of the top three skills employers demand across India’s tech sector, with demand for Python-skilled professionals growing at over 30% year-on-year. If you are thinking about a career shift into AI or machine learning, Python is the foundational language you will need.

    Python3 Command Not Found: Common Errors and Fixes

    The most common beginner errors when trying to run a Python program are predictable and fixable. Here is what usually goes wrong:

    • ModuleNotFoundError: You have not installed the package. Run pip install packagename.
    • SyntaxError: A typo, missing colon, or wrong indentation. Python is strict about whitespace.
    • python is not recognized: PATH was not set during Windows installation. Re-run the installer.
    • Permission denied (Ubuntu): You forgot chmod +x or you are running in a restricted directory.
    • IndentationError: You mixed tabs and spaces. Use spaces consistently (four spaces per indent level is the Python standard).
    • python3 command not found: Python 3 is not installed or not on your PATH. Run sudo apt install python3 on Ubuntu or reinstall from python.org on Windows and Mac.

    If your script runs but produces unexpected output, add print() statements around variables to see what values Python is actually working with. It is the simplest debugging technique and it works every single time.

    IDE Comparison: Which Tool Should You Use to Run Python Programs?

    IDE / Editor Cost Best For Beginner Rating Key Feature
    VS Code Free All-round development 5/5 Python extension, F5 run, Git integration
    PyCharm Community Free Larger Python projects 4/5 Auto virtual environment, smart refactoring
    IDLE Free (bundled) Absolute beginners 3/5 Ships with Python, zero setup
    Jupyter Notebook Free Data science and analysis 4/5 Cell-by-cell script execution, inline charts

    Learning to run a Python program also pairs naturally with understanding how modern tools like AI agents and agentic AI systems are built, since most of that tooling is Python-first. If you are serious about building a career in tech, the skills compound quickly.

    Students using GitHub for version control can get free access to tools and resources through the GitHub Education Program, which is worth setting up alongside your Python environment from day one.

    Once you are comfortable running Python scripts and managing virtual environments, the next natural step is picking a domain: web development with Flask or Django, data analysis with Pandas, or cybersecurity scripting. Each of these is a viable career path, and Python is the common thread. You can explore structured pathways for all of them through the 3.0 University learning hub.

    The highest-growth tech careers in India right now in AI, blockchain, and data science all list Python as either a required or strongly preferred skill. Starting with the basics covered in this guide puts you on the right track for any of them.

    If you want to go further faster, 3.0 University’s online certification courses in Cybersecurity, Ethical Hacking, AI, Blockchain, and Web3 are built for students, working professionals, and career switchers who want practical, industry-ready skills, not just theory. The Python you learn here is the same Python you will use in every one of those fields.

    Frequently Asked Questions

    How do I run a Python program?

    Install Python from python.org, save your code in a file ending in .py, open your terminal, navigate to the file folder using the cd command, and type python script.py (Windows) or python3 script.py (Mac/Linux). The output appears in the terminal immediately. An IDE like VS Code lets you run a Python program with a single button press using F5.

    How do I run Python from the terminal?

    Open your terminal or Command Prompt, use cd foldername to move into the directory containing your script, then run python3 script.py. On Windows, the command is usually just python script.py. You can also start an interactive Python session by typing python3 with no filename, which is useful for quick tests and calculations.

    How do I run Python scripts on Ubuntu?

    On Ubuntu, Python 3 is typically pre-installed. Open a terminal and run python3 script.py. To make a script directly executable, add #!/usr/bin/env python3 as the first line, then run chmod +x script.py to grant execute permission. After that, ./script.py runs it without needing to type python3 each time. Use sudo apt install python3 if Python is not available.

    Is Python easy to learn for beginners?

    Yes, Python is widely considered the most beginner-friendly general-purpose language. Its syntax is clean, readable, and forgiving compared to C or Java. A motivated beginner can write working scripts in a week. Realistically, expect four to six weeks of consistent practice before you feel genuinely comfortable. The massive community means answers to almost every beginner question already exist online.

    Why does my Python file not run?

    The most common reasons are: Python is not added to PATH on Windows, you are using python instead of python3 on Linux or Mac, there is a syntax error in your code, or you are running the command from the wrong directory. Check each of these in order. Run python –version or python3 –version first to confirm the interpreter is accessible from your terminal.

    What is the difference between python and python3 commands?

    On Windows, python typically points to the latest installed version (Python 3.x if that is what you installed). On macOS and Linux, python may still point to the legacy Python 2 interpreter, while python3 explicitly calls Python 3. Always use python3 on Mac and Linux to avoid running your script with the wrong interpreter.

    Last updated: June 2025. Reviewed by the 3University editorial team.

    • Share:
    3.0 University

    Previous post

    How to Compile and Run a Java Program (CMD, Notepad, VS Code)
    August 16, 2026

    Next post

    How to Run PHP, HTML and JavaScript Programs on Your Computer
    August 16, 2026

    You may also like

    Free AI Certificate Course by Government of India
    FREE AI Course with Certificate Launched by Govt of India
    June 19, 2026
    Highest Paid Professions in India
    Highest Paid Profession in India
    June 12, 2026
    Cyber Security Course Eligibility
    Cyber Security Course Eligibility
    June 11, 2026

    Leave A Reply Cancel reply

    You must be logged in to post a comment.

    3.0 University is a pioneering academic initiative for creating a comprehensive knowledge ecosystem for emerging technologies. We have developed an in-house suite of course offerings for retail, institutional market participants and industry-at-large. 

    Facebook X-twitter Instagram Linkedin
    Quick Links
    • About us
    • Courses
    • Become a Partner
    • Contact Us
    • Blog
    • Learn
    Trending Courses
    • Certified SOC Analyst
    • Certified Ethical Hacker v13 Program
    • Certified Penitration Testing Professional
    • Full Stack Blockchain Developer
    • Certified AI Program Manager
    Policies
    • Privacy Policy
    • Terms and Conditions
    • Disclaimer
    • Refund Policy
    Contact Us
    FT Tower, CTS No. 256 & 257, Suren Road, Chakala, Andheri (E), Mumbai-400093 India.

    +91 8657961141

    support@3university.io

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Register a new account

    Are you a member? Login now

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Register a new account

    Are you a member? Login now

    Sign In

    Welcome back! Or create an account

    OR
    Forgot password?

    Need a new verification email?

    Don't have an account? Register

    Create Account

    Already have an account? Sign in

    OR

    Already have an account? Log in

    Reset Password

    Enter your email and we'll send you a reset link.

    ← Back to login

    Check Your Email

    Almost there!
    We have sent a verification link to your email address. Please check your inbox (and spam folder) and click the link to activate your account.

    Didn't receive the email? Enter your address to resend:

    Already verified? Sign in