Let us install the Python step by step to create python setup on windows and possible ways to run the code.
Let us see how to download Python :
As we all know Python is an all-rounder, so it is a scripting language supported by different platforms like Linux, Windows, Perl, etc..And also it is platform independent so that we can just download and run the program anywhere, but in a practical way, we need some Editor.
The IDLE, which is nothing but an Integrated Development Environment for Python, Python IDLE is a simple editor which provides the Basic Features of Integrated Development Environment.
This is also called a REPL tool where R means Read, E means Evolve and P means Print, L means Loop, this tool helps us to work with Python syntax easily and also the IDLE helps in an only small type of applications and not for big applications
Now let us see how to use this Python IDLE
10+20and press enter, it will return the output as 30
20>50let us see what it will return
And also we can save the codes in the Python IDLE, let me show you how to do that, on the top of the Python shell page, you will see some tabs like File, Edit, Run, Debug, etc.. write some code by clicking on a file and then save it in your project folder.
Now I am going to save this file as
As this is a Python program, you need to save this by using .py extension and to Run this code there is Run Tab, just right click on it and click on Run Module so that Python will run the code and execute the output or else you can use the short cut to run just by clicking on F5 button.
#Read a number from the keyboard and print welcome message those number of times n = int(input('Enter some Number:')) for i in range(n): print('welcome to Chercher.tech')
The Output is :
We can also execute the programs by using the command prompt, so just go to windows and type cmd, the command prompt page will open and now enter as python so you are directed to python shell so now you can enter the input as Print('Hello World').
And also you can see some more examples which I executed in the command prompt
And I will get the output as below:
We had written code by using the IDLE and saved asDemo.py so we can execute this by using the command prompt as
First, open the
cmd and then
cd into the folder where you have saved the demo files, which you are worked on Python IDLE and then enter the file name followed by Python
As we have saved the program, once we run it, it will ask us to enter the number to print the output those many times, so here it is asking us to enter the number.
In the previous section, we have learned how to write the program in IDLE and how to run that program by using the command prompt, In the same way, we can write and run the program by using the Notepad.
First thing is, you have to install the Notepad or Notepad++ in your system and then open the notepad ++ page and enter the simple program to execute the sum and product of two numbers
#Read two numbers from the keyboard and print the sum and product n1 = int(input('Enter first Number:')) n2 = int(input('enter second Number:')) print('The Sum :', n1 + n2) print('The product:', n1 * n2)
After writing the program, save the same file by pressing
ctrl+s and save as sample.py in the python project folder.
Now open the command prompt and change the directory to your project folder, where I saved my Python project in the E folder and then move to your python codes folder and then run the code which we had written in the Notepad by using the command python sample.py
If it is successfully run the code then it will ask you to enter the numbers, so give any two numbers and then it will reply with its sum and product