What is Python and How is it Used?

What is Python and How is it Used?

Lesson Details:
July 10, 2020


I: Introduction

A: Introduction to programming coding languages

In this article I will discuss about programming languages and their use. Python is a general purpose, object oriented, high level programming language. It is designed to be fully interactive and supports structured programming, lexical scoping, and has automatic garbage collection. In python there is no need for writing the code in different parts of program separately. The code written in python can be intermingled with each other. This helps to make the code more readable and understandable. The readability of a program can be increased by using indentation. To make a comment in python, the # character is used at the beginning of a line to mark the comment.

Python is interpreted and interactive programming language that was developed by Guido Van Rossum. First version of python was released in the year 1991. It was developed on the C language and it has many similarities with other popular programming languages such as C, Java, Perl and Tcl. Python is available for free under open source license and is available for various platforms including Windows, Solaris and Macintosh OS X. Python can be embedded in applications written in other programming languages such as C and C++ and it can also be used as an extension language for other software development tools such as SQL database servers and web servers.

II: Body

What is python?

Python is a general purpose, object oriented, high level programming language that was developed by Guido Van Rossum in 1991. The interpreter for python was developed by Van Rossum and the name of the language comes from the comic book series called "the flying circus". Originally python was designed to be an easy to learn language but later it became a full featured general purpose programming language. Even though python is very simple to use and learn, it has many sophisticated features which makes it suitable for large projects. Python also allows the programmer to use procedural and object oriented programming techniques. The syntax of python is easy to understand because it is designed with simplicity in mind. Readable programs are easy to maintain because when the name of the variables are clear or have meaningful names, it becomes easier to understand what they are supposed to do. Python has keywords which are reserved words so they cannot be used as identifiers in python programs.

The following table shows some of the important features of python.

Feature Description Open-source free software License Python is an open source free software that can be used for personal or commercial applications with no restrictions. Object Oriented Programming It supports object oriented programming features in its core modules. Dynamic Typing The syntax of python is dynamic which means that the type of objects are not specified until run time. So if you assign one data type to another variable which is different from it, it will not generate any error message at compile time or during execution of program. Support for Unicode It supports Unicode characters which are needed to display text in any non English language. Can be Embedded into Other Applications Python can be embedded into applications written in other programming languages such as C and C++. It can also be used as an extension language for other software development tools such as SQL database servers and web servers. Easy Debugging Debugging in python is easy because of its readability. Exception Handling It handles exceptions gracefully which means that the program will not crash when an exception occurs. Can be Written Using Fewer Lines of Code Large programs can be written in fewer lines of code because of its simplicity due to its readability. Interactive Shell It comes with an interactive shell that allows you to execute commands interactively using python interpreter instead of using batch files or shell scripts.

Python Interpreter

The Python interpreter provides a runtime environment for executing programs written in python language. Programs written in python are run on top of this interpreter which provides all the basic services required by the python programs like memory allocation, debugging support, etc. The interpreter executes bytecodes which are generated by compiling the source code written in python language into byte codes. The python compiler only compiles the source code but does not execute it because compiling generates byte codes which are executed on top of interpreter itself.

How Does Python Work?

Python programs are primarily written using plain text files known as script files containing statements separated by new line characters (

). There are two ways to run python programs; One is using interactive shell of python called console interpreter and second one is running them on command line using python executable file called pythonw.exe . These two ways both work same way but only difference between them is that interactive shell executes script files directly whereas command line requires passing script file names as arguments to execute them which will execute them as bytecodes corresponding to respective extension types (.py, .pyc). The following example shows how a sample program can be run using command line option from command prompt using python executable file which creates a list containing 10 integers from 1 to 10 using nested for loops without using any conditionals. In addition to this example, we shall also see how this program can be run using interactive shell option from command prompt using python interpreter without specifying any additional arguments or filenames provided that path of interpreter is setup correctly otherwise python interpreter may fail to find script file properly.

Example: Running a Python Program From Command Line Using Python Executable File Pythonw -i Example1_noloop.py Program output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Number 10 not found in list! 5 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 250 255 260 265 270 275 280 285 290 295 300 305 310 315 320 325 330 335 340 345 350 355 360 365 370 375 380 385 390 395 400 405 410 415 420 425 425 431 436 441 446 451 455 460 465 470 475 480 485 490 495 500 505 510 515 520 525 530 535 540 545 550 555 560 565 570 575 579 584 589 594 599 604 609 614 619 625 630 635 640 645 650 655 660 665 670 675 680 685 690 695 700 705 710 715 720 725 730 735 740 745 750 755 760 765 770 775 780 785 790 795 800 805 810 815 820 825 830 835 840 845 850 855 860 865 870 875 880 885 890 895 900 905 910 910 920 925 930 935 940 945 950 955 960 965 970 975 980 985 990 995 1000 1005 1010 1015 1020 1025 1030 1035 1040 1045 1050 1055 1060 1065 1070 1075 1080 1085 1090 1095 1100 1105 1110 1115 1120 1125 1130 1135 1140 1145 1150 1155 1160 1165 1170 1175 1180 1185 1190 1195 1200 1205 1210 1215 1220 1225 1230 1235 1240 1245 1250 1255 1260 1265 1270 1275 1280 1285 1290 1295 1300 1305 1310 1315 1320 1325 1330 1335 1340 1345 1350 1355 1360 1365 1370 1375 1380 1385 1390 1395 1400 1405 1410 1415 1420 1425 1430 1435 1440 1445 1450 1455 1460 1465 1470 1475 1480 1485 1490 1495 1500 1505 1510 1515 1520 1525 1530 1535 1540 1545 1550 1555 1560 1565 1570 1575 1580 1585 1590 1595 1600 1605 1610 1615 1620 1625 1630 1635 1640 1645 1650 1655 1660 1665 1670 1675 1680 1685 1690 1695 1700 1705 1710 1715 1720 1725 1730 1735 1740 1745 1750 1755 1760 1765 1770 1775 1780 1785 1790 1795 1800 1805 1810 1815 1820 1825 1830 1840 1845 1850 1855 1860 1865 1870 1875 1880 1885 1890 1895 1900 1905 1910 1915 1920 1925 1930 1935 1940 1945 1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015 2020 2025 2030 2035 2040 2045 2050 2055 2060 2065 2070 2075 2080 2085 2090 2095 2100 2105 2110 2115 2120 2125 2130 2135 2140 2145 2150 2155 2160 2165

loader
Course content