Statements in Python

Statements in Python

In Python, statements are individual instructions or commands that the interpreter can execute. They are the basic building blocks of a program.

Examples are :

  • Assignment statement

    variable = value

      x = 5
  • Expression statement

answer = 10 + 2
  • Print statement
print("Hello all")

These are some of the statements in Python. There are many more, like break, continue, pass, if, else, elif, statements related to file handling, class and object definitions etc.

The print() and input() functions are fundamental in Python for displaying output to the console and obtaining input from the user, respectively.

  • The print() function is used to display output to the console.
print("Hello all, let's start coding")
# prints: hello all, let's start coding to the console
  • The input() function is used to read input from the user, which is always read as a string.
name = input("Enter your name: ")
print("Your name is",name)


Enter your name: Akash

Your name is Akash

When you run this code, it will prompt you to enter your name and print display it to output.

These are the simple Python statements with which we can start coding. We have already installed Python, so we can start coding from the next tutorial.

Stay Tuned !!!