Python Statement, Indentation ,Comments and DocString
Python Statements:
Instructions that a Python interpreter can execute are called statements.
Example:
1.Single line statement:
Instructions are end with in a line
Example:
Multi-line statement extend over multiple lines with the line continuation character (\).
Two types of continuations:
Example:
Note:
We can also put multiple statements in a single line using semicolons,
Example:
Most of the programming languages like C, C++, Java use braces { } to define a block of code. But Python uses indentation
Note:
A code block (body of a function, loop etc.) starts with indentation and ends with the first unindented line.
Python Comments:
Comments are very important while writing a program.
Note:
Hash (#) symbol to start writing a comment.
Two types of comments:
Previous page Next page
Python Statements:
Instructions that a Python interpreter can execute are called statements.
Example:
a=10Two types of Python Statements:
if statement, for statement, while statement etc.
- Single line statement
- Multi-line statement,
1.Single line statement:
Instructions are end with in a line
Example:
a=102.Multi-line statement:
Multi-line statement extend over multiple lines with the line continuation character (\).
Two types of continuations:
Explicit continuation ==> using \ character
Implicit continuation ==> using brackets [] or braces {}
Example:
Note:
We can also put multiple statements in a single line using semicolons,
Example:
a=20; b=10; c=30Python Indentation:
Most of the programming languages like C, C++, Java use braces { } to define a block of code. But Python uses indentation
Note:
A code block (body of a function, loop etc.) starts with indentation and ends with the first unindented line.
Indetation ==> Whitespaces , prefered is tabs, we can use any amount of space, but should be consistentIncorrect indentation will result into IndentationError
Python Comments:
Comments are very important while writing a program.
Note:
- It describes what's going on inside a program so that a person looking at the source code does not have a hard time figuring it out
- Basically, helpful to give the program logic for understandability
Hash (#) symbol to start writing a comment.
Two types of comments:
- Single line comments ==> using #
- Multi-line comments ==> using either ''' ''' or """ """
Docstring in Python:
Docstring is short for documentation string.
Note:
It is a string that occurs as the first statement in a module, function, class, or method definition. We must write what a function/class does in the docstring.
Syntax:
Within tuples quotes
""" """
Docstring is available to us as the attribute __doc__ of the function.
Previous page Next page



wow i learned many things here.clearly explained here
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course | Full Stack Training in Bangalore | Certification | Online Training Course | Full Stack Training in Hyderabad | Certification | Online Training Course | Full Stack Training in Pune | Certification | Online Training Course | Full Stack Training | Certification | Full Stack Online Training Course
I really liked your blog article. Really thank you! Really Cool.
ReplyDeletedata science training
python training
angular js training
wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
ReplyDeleteBest MPSC Coaching in Mumbai
Best IAS Coaching in Navi Mumbai
Best IAS Coaching in dadar
Best IAS Coaching in Thane
Best IAS Coaching in Andheri
Best IAS Coaching in Mumbai
Best ias coaching in borivali
Best IAS Coaching in bhandup
Staying compliant as a landlord can be challenging, especially with ever-changing safety and certification requirements. Resources like Landlord Certification are helpful for understanding inspections, certificates, and best practices. Having clear guidance makes managing rental properties much more straightforward and stress-free.
ReplyDeleteYour explanation of Python's advantages, especially the extensive libraries and easy syntax, is spot on. As someone who transitioned from manual testing to automation, I found that structured training made all the difference. For learners in Electronic City who want to build practical, job-ready skills, I strongly suggest real time software testing projects training in electronic city. Working on live projects alongside Python scripting helped me understand how to build robust test frameworks from scratch. Does your institute offer any hands-on Python projects as part of the training? That would be a great addition to this already helpful post.
ReplyDelete