Python Indentation
Python uses indentation to indicate a block of code.
Indentation is the spaces at the beginning of a code line.
Example:
if 10 > 3:
print("10 is greater than 3)
Comments:
Comments start with #
Example: # This is a Python Comment
print("Comments ignored")
Variables:
Variables stores the data value
Example:
i = 10
print (i)
Global Variables:
Variables created outside of the Function are global variables
Example:
a = "global"
def newFunction():
print("a is " + a)
newFunction()
Data Types:
Text: str
Numeric: int, float, complex
Sequence: list, tuple, range
Mapping: dict
Set: set, frozenset
Boolean: bool
Binary: bytes, bytearray, memoryview
None: NoneType
Casting:
use primitive types to cast the variables
Example:
a = int(1)
b = int(4.3)
No comments:
Post a Comment