Introduction to Python

Intro to python:-

Python is programming language develop by Guido Van Rossum, and released in 1991.

  Python is use for

       1.Web development.

       2.Mathematics

       3.Software development

       4.System scripting

 Why Python:-

·       Compare to all other programing languages the syntax of python is very easy to understand.

·       Python is use in web development ,software development ,system script, it is also use on servers to create web applications.

·       Python can also connect to database system. It can also read and modify files.

·       Python can be used to handle big data and perform complex mathematics.

·      Python can be used for rapid prototyping, or for production-ready software development.

Versions of Python:-   

·       There are manly two versions of python which is python2 and python3 but these days we only use python3 python2 also quit popular and it gets only security updates.

·       We can run python codes in any text editor like Notepad, Notepad++ and also with many other software and save the file with .py extension.


Python syntax compare to other programing languages:-

·       Python is similar to all other programing languages but the syntax is different from others it was designed for readability and has some similarities to English language.

·        Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.

·       Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.

How to Install Python in PC:-

Some PC has already install python to check that your PC has python or not.

·         If you using Windows OS then open your Command line(cmd.exe) then type

 

C:\Users\Your Name>python --version       

·         If you want to check python in Linux then open command line or on Mac OS open your terminal and type

 

Python --version

               

·         If you find that you don’t have python install in your computer then you can download it from https://www.python.org/

 

Let’s Start Python Program:-

·         After installing python to your PC open any of yours text editor and make a file and save it as .py extension here .py is for python after save the file open your terminal and write python and your file name.

Example: - your file name is helloworld.py then write python hello world.py

 

C:\Users\Your Name>python helloworld.py

 

Let’s write our first python program “helloworld.py” in any text editor.

 

helloworld.py

 

print("hello world")

 

 

 

Save your file. Open your command line and navigate the directory where you save your file, and run:

 

 C:\Users\Your Name>python helloworld.py

 

  The output should be like this:-

hello world

The output is shown in this way then your first python program is correct.

 

The Python Command line :-

Python gives us a option of command line by which we can write and run small programs in python command line without save any file in any of the text editor.

To open in Windows, Mac, Linux write this to command line

C:\Users\Your Name>python  

 

Or, there is also an option to run the python command line write “py” on cmd.

C:\Users\Your Name>py  

 

From here you write any python program including our previous program “helloworld.py”

Let’s see an example:-

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("helloworld")

         

It will write helloworld on your terminal

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("helloworld")

helloworld

When you are done with python command line you can simply write exit in command line in that way.

exit()

 

   

 



Comments