Python Unit - 1
Python Unit - 1
Documentation section:
Mention the program name.
Optional.
Import statements
Includes various in-built or user-defined modules.
Global declaration section
Variable that we can access from anywhere in the program
Class section
Information about the user-defined classes.
Subprogram section
Set of statements that will execute.
The source code executed by the Python interpreter is called (\n) used for the next line.
2. Conditional Statements
3. Looping Statements, Etc.,
1. Single Line Statements:
# used for comment.
Separated by semicolons (;)
Output
Example:
Program
Output
This makes code more readable for multiple functions and Example:
# statement 1 This
# statement 2 is
# ... a function
Using Pythons' default ASCII encoding is the best practice """This is a class"""
Example a class
It's best to use a space before and after an operator. Don't forget to update the comments while updating code.
Use a space after the comma is more readability. It's one of the most important things in coding.
Object:
An object is an instance of a class.
It is created from the class.
Attributes:
Attributes are data members.
Hold information about the object.
Defined within the class.
Methods:
Methods are functions.
Defined within a class. ------------------------------------- END -------------------------------------