.py". Working with packages and modules: Use the "import" statement to import a package or module."/> .py". Working with packages and modules: Use the "import" statement to import a package or module.">

Home  >  Article  >  Backend Development  >  How to use python after installation

How to use python after installation

下次还敢
下次还敢Original
2024-04-11 03:35:211125browse

To use an installed Python: Start an interactive shell: Enter "python" in the terminal. Use Python code in the shell: type the code and press Enter to execute it. Create a script: Create a .py file in a text editor and paste the code into it. Run the script: Navigate to the scripts folder in the terminal and enter "python .py". Working with packages and modules: Use the "import" statement to import a package or module.

How to use python after installation

How to use installed Python

After the installation is complete

  • Open a terminal or command prompt (depending on the operating system)
  • Enter the python command to start a Python interactive shell

Using Python in an interactive shell

  • #Type Python code in the shell and press Enter to execute it. For example:

    • ##print("Hello, world!") will print "Hello, world!"
    • x = 5 will Create a variable named x with the value 5
    • for i in range(5): will create a loop that loops 5 times

Create and run the script

    Create a file in a text editor and extend the code to
  • .py.
  • Paste the Python code into the file.
  • In the terminal or command prompt, navigate to the folder where the script is located.
  • Enter
  • python