Python is a high-lavel general-purpose programming language created by Guido van Rossum and released in 1991.It can be used in web development, software development, data science, machine learning and so on.Different platforms can used to learn python like Linux,Mac, Windows etc.Even you can use your Android phone to learn python,In this tutorial I am going to tell you that how you can learn python on your Android device with the termux application.
What is termux
termux is a terminal emulator for Android where you can run almost all of Linux commands.Termux is available on Google play store F-Droid.If you download if from F-Droid you will get the latest version ,you can also download it from Google playstore but it hasn't been updated in the Play Store for a long time.If you want to learn more about termux you can visit here.
What is python used for
Nowadays python has become most popular and widely used programming language over the world.Python can be used everywhere from creating a simple calculator to creating AI.
Python can be used for
• Web development
• Game Development
• Data Analysis
• Software development
• Machine learning
• Data Visualization
How to install python in termux
Installing python in termux is very easy ,follow the steps given below to install python on Android using termux
Step1
Open your termux application then update and upgrade the termux packages
Step2
Install python globally on Termux
By default python3 will be installed on your Termux and During the process if it print the message
Please type Y and press the ENTER key to continue the process.
After successfully installed python on Termux you can use the command
To see the python version
How to print hallow world message
After installing python on Termux you can run any python code on it.
1. Type python and press Enter
2. Write the one line python code
then press ENTR and it will print the message Hollow world as shown below.
3.press CTRL+D to return to termux.
How to write a simple python script
One line Python code can be easily executed in the manner described above.But if you want to run more than one Python code in one command, you need to create a Python file. So here we will learn how to create a Python file or script in Termux.
Step1
To do so at first we will need an editor on Termux so I will install the vi editor.
Step2
Copy the code given below
number = 2
while number < 5 :
print("Thank you")
number = number+1
And make a python file named demo.py with the command
Paste the all copied command on it and save the file with ESC then :wq then press ENTR.
Step3
Now to execute the python file demo.py use the command
It will display thee times "hallow world" message.
0 Comments