Monday 8 July 2019

How to write and execute Python program in your computer



How to write and Execute Python Program:

Three ways to write the python program:

1. By using commandLine prompt 
2. By using IDLE
3. By using any Pycharm By using commandLine prompt


1. By using command line prompt  

·    But to execute the python programs in command line prompt, first we need to set the path settings.

Setting class Python class path:

Steps to set the class path to execute python program on command line prompt.
1.   Open IDLE Software
2.   Type import os command àpress enter key
3.   Type os.path command and press enter key
4.   Now it will display the where the Python software is installed in your system.

Ex:
>>> import os
>>> os.path
<module 'ntpath' from 'C:\\Users\\myraj\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\ntpath.py'>
>>> 
5.   
Copy that path
Keep your mouse on “This PC” or My Computer-àright click—choose ‘properties’-àclick on ‘Advanced System Settings’-àit will opens one dialog boxàclick on ‘Environment Variables’--àclick on ‘Path’ from System Variables. -àeditànewàpaste the Python software address path.-àokàok-àok

1. Go to command prompt and press enter key.
2. Type “python” and press enter key
3. Write any python program.

Ex:

F:\>python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world")
hello world
>>> a=2
>>> b=4
>>> c=a+b
>>> print(c)
6
>>> 

1.         By using IDLE
Steps:
1. Type “IDLE” in windows button, now IDLE Software will open
2. Write any program and press enter

Ex:
>>> a=2
>>> b=8
>>> c=b-a
>>> print(c)
6
>>> 

By using the note pad:

Step1: Go to any directory create any folder. Ex: go to f drive, create folder (programs)
Step2: open any note pad:
Step 3: write any python program.
Ex: print(“Good afternoon”)
Step 4: save your python program with “.py” extension
Step 5: execute the python: go to dos prompt/command line prompt
Step 6: Go to your directory. Ex: f:
Step 7: Go to your programs folder.Ex: cd programs (press enter)
Step 8: execute the python program. Ex: python Ex.py (press enter)
Step 9: shows the output

Note: IDLE => Integrated Development and Learning environment


Youtube channel click here to see this video

Next Topic: Comment Lines in Python
Previous Topic: How to install Python

You may like the following topics:


How to install Pycharm Software: https://youtu.be/wooQnNqxCgk Other tutorials


5 comments:

  1. Sir today class post. Cheyyandi sir

    ReplyDelete
  2. Sir 10 th July notes post Chesapeake sir

    ReplyDelete
  3. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also 金融代写

    ReplyDelete

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...