Follow Us

How to Learn Python programming using Termux - 2020

Termux is a great tool that allows you to do hacking on you android phone one of the best thing about the termux app is that it allows you to install and run python on your android phone.


Python:

Python is a high-level interpreted language created by Guido van Rossum. If you are thinking about learning a programming language in 2020 python is the best language I can suggest you can create tools that will allow you to simplify your work python is easy to learn and if you are thinking about learning it using termux then this post is for you.

Using termux you can learn intermediate level python programming you can research on external moduls of python that will allow you to create some really useful projects. If you are really serious about python then I will suggest you learn from multiple sources and learn topic wise.



The benefit of learning python using Termux:


Termux is portable. When you start learning to program you get new ideas while you are not at your desk if you are working on some project then you certainly realize how you can solve that bug you were stuck from the past few days. Using termux you can code anywhere and even without internet so as long is python package is in your termux app you can code in Python language no matter where you are. 

You can download a certain project from the internet and then paste it into your termux app and then you can execute it. You can attach a physical keyboard with your phone and then it will be more easy to do programming on your phone.


How to install Python3 in your Termux app:

Install Python2:

If you are going to learn python don't have to install python2 you on your termux app I am just showing you how to install python2 you because a lot of project on GitHub still works on Python2 and if it's giving you error with python3 while execution you can learn it with Python 2 and maybe it will work most of the time
pkg install python2 

This command will install 5MB or archive in termux app.


Run Python2:
To run Python2 you just have to type:
python2 



Install Python3:

To install python3 on your termux app you just have to install Python package from termux repositories.
pkg install python

It will install approximately 9 MB achieve and it will take up to 49 MB of space in your phone.

Run Python3:
To run Python3 you just have to type:
python

or you can also type python3.


Modules in python:

Modules are files that contains codes. There are a lot of Modules in python and every module enable you to do something different than others.pygames is a module that allows you to create games using python, Tkinter is a tool that is used for making GUI for python programs. Selenium is a Module that is use to Automate browsers. Requests is a module that use to send HTTP requests.

How to install Modules in Python:
To install a module in python you just have to type below command and the green part of the code will change with the name of the module you want to install.
pip install requests

this is the most common way to install the modules if this is not working then you can visit this site to learn about the package installation.


Tools to Write Python programs in termux:

To write a Python program you have to open a text editor in termux you can use Nano which is a good text editor to write a Python program. When you will give you a clean interface where the color of the commands will be changed which will make code writing easy

Install nano text Editor:

Type below command to install nano text editor in python. Which will help us to create 
pkg install nano


Enable Extra Keys In termux:

If you are going to write code on termux you have to move your cursor a lot for editing purposes.
In termux app you can enable Extra keys that will allow you to navigate quickly.
I have written a complete post on How you can enable Extra Keys in termux using Single command.it will only take 30 sec to enable those keys so you must checkout.



Link : How to Enable Extra Keys in Termux In Less the 1 Min




Write Your First Python programs in termux:

Step1:
In Python, you have to create a .py file that will contain your python code.type below command to create a py file.
nano Hello.py

Nano : is tool name.which will open a text editor.
Hello : is a file name , you can change it with any name you want.
.py : is python file extension like .txt is Extention of text file or .mp3 is for sound.



Step2:
1. Now type any Python code You want, if you don't know anything about python you can type and this code will print Hello world on your screen.
print("hello world")

2.Press CTRL+X.
3.Press Y and then press Enter.




Step3:
Type Python space file name .py to run the python file you just have created.
python Hello.py

This will print "Hello World" on your termux screen.



Start Writing your own Python programs in termux:

Now you know that How you can create a python file in termux and you also know how you can run that file the only and biggest thing that you have to do is learn Python programming. There are hundreds of websites and YouTube channels where you can learn python. 

I can give you a list of websites where you can easily learn python programming from beginner to advanced. 

Here are some basic Python codes that you can copy-paste and get familiar with python in termux.


Sum of 2 Numbers in python:



save this code in nano as anyname.py and run it and using this code you can find sum of any number.



Generate Random Gmail :
Generate a random Gmail using the below code, This Gmail will not be valid to log in but you can use this Gmail to log in at any site where Confirming Gmail is not required.



save this file as anyname.py and run it and using this code you can Generate a random Gmail address.



Generate a Random password:
Below will generate a random password that will be strong and not easily hackable by brute force attack or dictionary attack




Create Your Own Falling Effect in termux:
Using the Below code you will be able to Create a matrix effect in termux and only using python.



save this code in nano as anyname.py and run it and You will see a matrix effect on your terminal.Please Adjust Your screen to make it fit perfectly,it will look cooler if you have installed a green theme in termux. If you want to install a Green theme on your termux app then you can read this post.[Install Hackers theme in termux]

Conclusion:

Python is the coolest programming language for me (at least today). The best thing about python is, it is easy and a lot of projects are available on the internet. half of the hacking tools for termux are written in python. I know Learning Python in your phone is a little difficult but I have also learned to program using my phone so it is not that difficult. there are also IDEs for python on play store but I love to code on termux because this is the only app where my all-important tools are available so I am not gonna switch to something else just for python. You can create really awesome project in python by learning some modules like requests and beautiful soup.i have just added 4 codes but i will add more whenever i create something new so keep checking this post one in a while.



Post a comment

0 Comments