Skip to content

Latest commit

 

History

History
62 lines (52 loc) · 1.83 KB

File metadata and controls

62 lines (52 loc) · 1.83 KB

How To write first Basic Python Program.

As we have already installed required python version and set up in our machine

Now we are here to learn first some basic concepts about python program

What is the use of python idle terminal

you can write your small code on idle terminal and press enter to execute

Example:

  print("I am from terminal ")

you can use python idle terminal as calculator Example:

  >5+6-7

and press enter to execute you will get final result in next line

  >4

How to write program in idle and run in python?

  • After opening of idle terminal just press Ctrl+n to open a notepad like python text editor.
  • And write required code inside editor.
  • Now save that file as your required name with extension.py

Example:

  filename.py

How To Run Python file.

There are 2 way to run python file

  1. Normal
  • Open Python file in python IDLE.
  • Now just press f5 or go to run menu option and select run to execute the python file.
  • Now result will displayed on your python Shell.
  1. Using Terminal
  • Open command prompt or terminal in your shell.
  • Go to directory copy path and in command prompt and change command prompt derectory using following command.
  >cd "directory path"
  • after changing directory just type
  dir>python filename.py
  • Now your required result will be displayed on command prompt

Error And Solution

  • if "python command is not recognized" occured Solution:
    - Add your python installed path to enviornment variable.
    - And Also Add python/scripts path to enviornment variable.
    
    for more Tutorial about how to add path to enviornment variable follow this Tutorial