Python is an interpreted, high-level and general-purpose programming language. Python’s design philosophy emphasizes code readability with its notable use of significant indentation.
It was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with an emphasis on code readability, and its syntax allows programmers to express their concepts in fewer lines of code.
Python lets you work quickly and integrate systems more efficiently.
There are two major versions of Python language Python 2 and Python 3. Both are different in some ways.
Getting Started
1. Get an Interpreter
Before starting any programming language we need an interpreter to interpret and run our programs. There are several online platforms for running various programs. Some of them are as below
- Ideone Ideone is an online compiler and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages.
- CodePad codepad is an online compiler/interpreter, and a simple collaboration tool.
- Geeksforgeeks A Computer Science portal for geeks also provides a platform to run our programs.
Windows: There are many interpreters available freely to run Python scripts like IDLE (Integrated Development Environment) that comes bundled with the Python software downloaded from http://python.org/.
Linux: Python comes preinstalled with popular Linux distros such as Ubuntu and Fedora. To check which version of Python you’re running, type “python” in the terminal emulator. The interpreter should start and print the version number.
macOS: Generally, Python 2.7 comes bundled with macOS. You’ll have to manually install Python 3 from http://python.org/.
2) Writing our first program:
Just type in the following code after you start the interpreter.
# Script Begins
print("Hello World")
# Scripts Ends
Output:
Hello World
Let’s analyze the script line by line.
Line 1: [# Script Begins] In Python, comments begin with a #. This statement is ignored by the interpreter and serves as documentation for our code.
Line 2: [print(“GeeksQuiz”)] To print something on the console, print() function is used. This function also adds a newline after our message is printed(unlike in C). Note that in Python 2, “print” is not a function but a keyword and therefore can be used without parentheses. However, in Python 3, it is a function and must be invoked with parentheses.
Line 3: [# Script Ends] This is just another comment like in Line 1.