Home EDUCATION Introduction to Python for Beginners
Introduction to Python for Beginners

Introduction to Python for Beginners

by Altaf

Python is a general-purpose programming language that is rapidly gaining popularity in the fields of data science and artificial intelligence. Guido van Rossum established it in 1991, and the Python Software Foundation continues to develop it. Its syntax was created with code readability in mind, allowing programmers to communicate their ideas in fewer lines of code. Python is a programming language that allows you to operate more quickly and efficiently with systems.

Let’s start with Python for Beginners:

1.Find an Interpreter

Before we start Python programming, we need to have an interpreter to interpret and run our programs. There are certain online interpreters like Codepad, OnlineGDB etc.

Windows: IDLE (Integrated Development Environment), which comes packed with the Python software downloaded from http://python.org/, is one of many free interpreters available for running Python programmes.

Python is preinstalled on popular Linux distributions like Ubuntu and Fedora. In the terminal emulator, type “python” to see the version of Python you’re using. Start the interpreter and print the version number.

Python 2.7 is included with macOS in most cases. Python 3 must be manually installed from http://python.org/.

2) Writing our first program:

Start with a simple ‘Hello World’ program in any interpreter. It takes only one line of code to print anything.



Print(“Hello World”) 



Hello World

Let’s have a look at the script one line at a time.

  • The interpreter ignores this sentence, however it provides as documentation for our code.
  • [print(“Hello World”)] on line 2. The print() function is used to print something to the console. After our message is produced, this function additionally adds a newline (unlike in C). Note that in Python 2, “print” is a keyword rather than a function, and therefore can be used without parentheses. In Python 3, however, it is a function that must be called with parentheses.
  • #end. This is essentially a repeat of Line 1’s comment.

Let us try another way to execute the same ‘Hello World’. 

print “Hello World”

This produces the following result −

Hello World

2.Python Identifier

A Python identifier is a name for a variable, function, class, module, or other object in Python. An identifier begins with a letter from A to Z, or a to z, or an underscore (_), then zero or more letters, underscores, or numbers (0 to 9).

Within identifiers, punctuation characters like @, $, and percent are not allowed. Python is a programming language that is case sensitive. As a result, in Python, manpower and manpower are two separate identifiers.

The naming standards for Python identifiers are as follows:

  • The name of the class begins with an uppercase letter. The beginning of all other identifiers is a lowercase letter.
  • The presence of a single leading underscore in an identifier implies that it is private.
  • An identification that begins with two leading underscores is considered to be very private.
  • The identifier is a language-defined special name if it also ends with two trailing underscores.

Reserved Words

The Python keywords are listed in the table below. You can’t use these terms as constants, variables, or any other identifier names since they’re reserved. Only lowercase letters appear in the Python keywords.

and, exec, not, assert, finally, or, break, for, pass, class, from, print, continue, global, raise, def, if, return, del, import, try, elif, in, while else, is, with, except, lambda, yield.

Lines and Indentation

There are no brackets in Python to mark code blocks for class and function definitions or flow control. Line indentation, which is strictly enforced, is used to designate code blocks.

The indentation can be any number of spaces, but all statements in the block must be indented the same amount. For instance,

if True:

print “True”


print “False”

However, the following block generates an error −

if True:

print “Answer”

print “True”


print “Answer”

print “False”

Thus, in Python, a block is formed by all continuous lines indented by the same amount of spaces.

Multi-Line Statements

In Python, statements usually conclude on a new line. The line continuation character () in Python, on the other hand, can be used to indicate that the line should continue. For instance,

total = item_one + \

item_two + \


The line continuation character is not required for statements enclosed in the [],{} or (). For instance,

days = [‘Monday’, ‘Tuesday’, ‘Wednesday’,

‘Thursday’, ‘Friday’]

Quotation in Python

To designate string literals, Python accepts single (‘), double (“), and triple (“‘ or “””) quotes, as long as the same type of quote begins and ends the string.

To span the string across multiple lines, triple quotes are utilised. All of the following, for example, are legal:

word = ‘word’

sentence = “This is a sentence.”

paragraph = “””This is a paragraph. It contains various lines”””

Comments in Python

A comment begins with a hash sign (#) outside of a string literal. The Python interpreter ignores any characters after the # and up to the end of the physical line as part of the comment.

# First comment

print “Hello, Python!” # second comment

This produces the following result −

Hello, Python!

After a statement or expression, you can type a comment on the same line.

“Pokemon” is the name of the character #This is another comment.

You can comment multiple lines as follows −

# This is a comment.

# I am commenting again.

# I am commenting again.

# I said that already.

The Python interpreter ignores the following triple-quoted string, which can be used as a multiline comment:


I am commenting a multiline



Using Blank Lines

A blank line is a line that contains simply whitespace and may or may not have a comment, and Python ignores it completely.

A multiline statement must be terminated in an interactive interpreter session by entering an empty physical line.

Hope this article helps you a lot in understanding this topic. If you’re interested in free courses with certificate, So enroll today on the Great Learning Programme.

Related Posts

Leave a Comment