Interviews - C# Corner

Dinesh Beniwal
Is indentation required in python?
By Dinesh Beniwal in Python onJun 20 2019
  • Rohit Gupta
    Jul, 2019 15

    identation is the mechanism by which a code block is represnted in python. Unlike languages like Java or C++ where the code block is represented by curly braces, in python the need of putting and montitoring the start and end of barces was elemenated

    Since there is no other way of representing code block, hence the need of indentation becomes unavoidable

    For Example:


    1. int add(iint a, int b)
    2. {
    3. return a+b;
    4. }


    1. def sum(a,b):
    2. return a+b

    • 0
  • Bidyasagar Mishra
    Jul, 2019 5

    Yes, Where in other programming languages the indentation in code is for readability only, in Python the indentation is very important.
    Python uses indentation to indicate a block of code.

    1. if 5>2:
    2. print("five is greater than two")

    • 0

Most Popular Companies

Most Popular Job Functions