Python for beginners

Posted by Andor on Jan 10, 2018, in Programming


Python is an object-oriented, potential high-level programming language that Guido van Rossum created. It possesses a simple and easy to use syntax that makes it an ideal language for individuals trying to master computer programming for the first time. It is basically a general purpose language that possesses varied applications from Web development such as Django and Bottle, mathematical and scientific computing like SymPy, Orange, NumPy to that of graphical desktop use Interfaces like Panda3D and Pygame. The language’s syntax is clean as well as length of code is comparatively short. You will enjoy working in Python as it permits to think regarding the issue instead of focusing on syntax. 

History

Guido van Rossum created this pretty old language, Python. The design started in late 1980s and first was released in February, 1991. The name ‘Python’ was given after a comedy series of late seventies called ‘Monty Python’s Flying Circus’ of which Rossum was fan. He was operating on Amoeba distributed-operating system group in late 1980s. He wished to employ an explicated language such as ABC which can access system calls of Amoeba. Hence, Rossum decided to develop a language which was expandable. This ultimately resulted to design of a new language that was later termed as Python. 

Basic features of Python programming

  • Easy to learn - Syntax of Python is very elegant and simple. It is very easier to read as well as write its programs in comparison to other languages such as Java, C# or C++. This language makes the programming fun and lets one to concentrate on the solution instead of syntax. Python would be a great choice for beginners or starters. 
  • Free and Open source - Python can be freely used and distributed, also for using in commercial purpose. You can employ as well as distribute the software written in it and even make modifications to the source code of Python. 
  • Embeddable and extensible - If you need high performance, you would be able to combine easily the pieces of C/C++ or any other languages with code of Python. It would offer your application high-performance and scripting abilities that other languages might not offer out of the box. 
  • High-level interpreted language - You do not have to take stress about unnerving task such as garbage collection, memory management and etc. While running Python code, it will automatically convert your code to your computer language. There is no requirement to worry regarding lower-level operations. 

How to run it locally?

For overcoming the issues of async requests, you have to run them via a local web server. One of the easiest ways for doing this is using SimpleHTTPServer module of Python. For doing this, you would have to install Python. It will be available automatically in Mac OS X or Linux. For users of Windows, you could get an installer from homepage of Python and install it by:

  • Going to python.org
  • A link for Python 3.xxx will be present under the download section
  • At the page’s bottom, select the Windows x86 executable installer to download 
  • Run it after the download is finished
  • Assure to check ‘Add Python 3.xxx to PATH’ checkbox on the first installer page
  • Click on ‘install’ and click on ‘close’ while the installation completes
  • Now, you will be opening your command prompt/ terminal and for checking whether Python is installed, you need to enter the command: python –V
  • It would give back a version number. If it is OK, you will be navigating to the directory, employing the ‘cd’ command
  • Now, you would be entering the command to begin up the server in that directory
  • It would run the directory contents by default on a local web server on the port 8000. You can go the URL localhost: 8000 to reach this server in your web browser. At this place, you will see the directory contents listed. You can click on the HTML file that you would like to run

How this program functions?

Line 1 - # add two numbers

Lines that begin with ‘#’ in the Python programming are a comment. Comments are employed in programming for describing the purpose of code. It aids you and other programmers to apprehend the intent of code. Interpreters and compilers entirely ignore the comments. 

Line 2 – num1 = 2

‘num1’ here is a variable. You would be able to store a value in one variable. ‘2’ is stored here in this variable.

Line 3 – num2 = 6

Like the same way, ‘6’ is stored here in variable ‘num2’. 

Line 4 – sum = num1 + num2

Here, ‘num1’ and ‘num2’ variables are added employing ‘+’ operator. The result of this addition is later stored in other ‘sum’ variable. 

Line 5 – print(sum)

This print(sum) function is known to print the output to the device screen. In this case, it will print ‘8’ on the screen. 

Some Significant Things to Remember

For representing a statement in Python, enter (newline) is employed. It is optional to use semicolon at the end of a statement that is unlike the languages such as JavaScript, C/C++ or PHP. It is recommended even for omitting semicolon at the end of statements in Python. However, indentations are employed for representing a block in place of curly braces {}. 


Well, Python is an outstanding language that comes with a simple syntax and short code length and this makes it easier to write as well as understand. If you are a starter in programming, this language would be a great choice. It is not only a good language to learn programming but even perfect language to possess in one’s arsenal.