Important Python Concept

Basics of syntax

To start, make sure you have either have Python installed on your system or have an online compiler up and running.

The Print Statement

 

Let’s start from the most basic yet important part i.e the print statement.
The print function() is used to display any text or message which we want to be displayed on the output window of Python.
Let’s take an example:

 

Example 1:

 

print("hi")

 

OUTPUT:
hi

 

In the above example, we printed a very basic text using the print function().
Make sure to use single quotations ‘ ‘ or double quotations ” ” whenever using the print function for words/lines/statements.
Your turn, try printing your name maybe? 🙂

 

Example 2:

 

Let’s now try printing a number using the print function():
print(456)

 

print(456)

 

OUTPUT:
456

 

Noticed something?
That’s right! Printing a number won’t require any quotations. But make sure you use the round parentheses.

 

Example 3:

 

We can also add numbers using the print function:

 

a = 3
b = 5
c = a + b
print(c)

 

OUTPUT:
8

 

Here, a and b are variables i.e they have been given some specific value (in this case 3 and 5).
Then c another variable has been assigned the added value of 3 and 5.
Simple right?

 

Example 4:

 

Let’s try to multiply two numbers in this example:

 

a = 3
b = 5
c = a * b
print(c)

 

OUTPUT:
15

 

When multiplying, the asterisk(*) symbol is used as the multiplication symbol.

 

Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?