Through Terminal
Open Terminal in Ubuntu
Run this command line
sudo apt install python3.10
or
sudo apt-get install python3
check the latest version
Type Y and press enter, after you see software will install like below.
Through Online
Go to Official website
https://www.python.org/downloads/
Click on download button.
Through Terminal
First download the software
➔ Go to the location where Python software is saved
➔ Right click on python software and click on “Run as administrator”
Then setup will come
Click on Install now then installation process will go on, after you see the message “Setup was successful”
➔ Then click on close
➔ When Python is installed in windows, a program called IDLE is also installed along with it. It provides graphical user interface to work with Python.
➔ This is how an IDLE looks like
In python we can run the code in various ways.
As the name suggests, allows us to interact with operating system.
Here, we type a Python statement and the interpreter displays the result(s) immediately.
We execute small statements here.
We can give our expressions/ commands/ statements after
Interpreter uses prompt to indicate that it is ready to execute instructions
Open Idle
After the prompt you can run your program.
While writing in Python, remember Python is case sensitive. That means a & A are different in Python.
Press control D or quit () is used to close the interpreter
Drawbacks with IDE mode
We can not run large code
We can not reuse the code once we close IDLE.
Editing is not possible once code is run.
In script mode, we type Python program in a file and then use the interpreter to execute the content from the file. Working in interactive mode is convenient for beginners and for testing small pieces of code, as we can test them immediately. But for coding more than few lines, we should always save our code so that we may modify and reuse the code.
Python, in interactive mode, is good enough to learn, experiment or explore, but it’s only drawback is that we cannot save the statements for further use and we have to retype all the statements to re-run them.
To create and run a Python script, we will use following steps in IDLE
Open python IDLE
Go to file and click on new
After write code
Save the file
Run/Execute the file by clicking Run from menu/press F5 to run the file
• Go to file in python shell, click on new file then a new window will appear, There we write code like below ( You can write in a text document/Notepad and save the file with .py extension).
• print (“hello world, happy learning python”).
• save the file with any name with .py extension , after saving just click on run/press f5 to see the output.
• We can use plain text file to write python code, then open terminal/command prompt then go to file location then type the following to execute the file python( 1.py )