Hello to everybody!
Python is currently one of the most widely used programming languages worldwide. Python contains numerous libraries. You may create incredible applications quickly and easily with the help of Python libraries.
Don't worry if you want to study Python and use Python but don't have a computer. Your phone is more than simply a gadget for watching entertainment. It's more than you could imagine. You will find out how to install Python on your Android device and how to run Python programs in this article.
Before beginning, You need an application named Termux. It is a Linux terminal environment running on Android. Here is a Basic Termux article I've already written. It will help you in using Termux and it's recommended that you read it first if you are unfamiliar with the program. A text editor named Vim editor is also necessary. You may read about the installation and fundamentals of Vim in this post.
Python installation
Follow the steps and execute this command in your Termux.
We must first update and upgrade termux using this command.
apt-get update & apt-get upgrade -y
Now use the pkg package manager to install Python.
pkg install python
Once installed successfully, open your terminal and execute python --version.
python --version
If you see "python version," then your machine has successfully installed Python.
Running Python
Now It's time to run a python program. A text editor is first required. Vim, which I just mentioned, is what I'm using in this tutorial. Run the following command.
vim myFirst.py
The text editor Vim will create a python file named myFirst.py and open with it's editor.
Now, type any Python code. Instead, you can copy this code. It's a simple "Hello, world!" Python code.
print("Hello, World!")
Paste it into the Vim text editor, then use the :wq command to save and close the editor.
Run the Python file you just created at this point. Use python keyword and then write myFirst.py, the name of Python file.
python myFirst.py
The output of a successful run will be this.
~ $ python myFirst.py
Hello, World!
Congratulations! You successfully ran the Python application.
Conclution
This article began with instructions on how to install Python on an Android smartphone before moving on to demonstrate how to run Python programs on Android. I hope this material will be useful to you. Feel free to share your thoughts in the comment section if you encountered any issues. Happy learning Python!