Python Identifiers:
Python identifier is a name used to identify a variable function, class, module, or other object.Identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).
Which it donot allow while declaring identifiers
Punctuation characters such as @, $, and % within identifiers.Note
Python is a case sensitive programming language.Example
SCANFTREE and scanftree are two different words.Some Notifiable Conventions used in decalring an identifier
- Class names start with an uppercase letter and all other identifiers with a lowercase letter.
- Starting an identifier with a single leading underscore indicates by convention that the identifier is meant to be private.
- Starting an identifier with two leading underscores indicates a strongly private identifier.
- If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.
Reserved Words
only | and | exec | not |
assert | finally | or | break |
for | pass | class | from |
continue | global | raise | |
def | if | return | del |
import | try | elif | in |
while | else | is | with |
except | lambda | yield | for |
Lines and Indentation
Ooh ! There is no braces while writing the code then you are wondering that how will you manage the blocks of code.
Solution is here blocks are denoted by line indentation
Note
When you are writing a block then be careful about spaces before every line so that it appears in the same block. If it is.
For example:
if True: print "True" else: print "False"
Be careful from not following the wrong approach, as
if True: print "scanftree" print "True" else: print "scanftree" print "False"
Comment
whatever is written # followed by comment , is treated as comment
Example
print 'sanftree.com' # this is a comment
In the next chapter you are going to learn some basic variables used in python