google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Naming Conventions( Variable, Identifiers, Literals and Keywords)

Naming Conventions( Variable, Identifiers, Literals and Keywords)

0


Naming Convention



1. Identifiers in Python:

A Python identifier is a name used to identify a variable, function, class, module or other object. An 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).


Python does not allow punctuation characters such as @, $, and % within identifiers. Python is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in Python.


2. Literals in Python:

Literals in Python can be defined as number, text, or  other data that represent values to be stored in variables.

Example of String Literals in Python.

name = ‘Johni’ , fname =“johny”

Example of Integer Literals in Python

(numeric literal)  age = 22

Example of Float Literals in Python

(numeric literal)  height = 6.2

Example of Special Literals in Python  

name = None


3. Variable in Python:

A Python variable is a memory space allocated for storing values. A variable, in other words, provides data to the computer for processing.

In Python, each value has a datatype. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc. Variables can be declared by any name or even alphabets with Naming Convention Rules.

The Naming Convention Rules are:

1. Variable name should start with letter(a-zA-Z) or underscore (_).

Valid : age , _age , Age

Invalid : 1age

2. In variable name, no special characters allowed other than underscore (_).

Valid : age_ , _age

Invalid : age_*

3.Variables are case sensitive.

age and Age are different, since variable names are case sensitive.

4.Variable name can have numbers but not at the beginning.

Example: Age1

5.Variable name should not be a Python keyword. Keywords are also called as reserved

words.

Example

pass, break, continue.. etc are reserved for special meaning in Python. So, we should not declare keyword as a variable name.


4. Keywords in Python:


keywords are special Type of words reserved for a  specific meanings and purposes and can’t be used for anywhere outside the specific purposes.
These keywords are always available—you’ll never have to import them into your code.

keywords list change time to time as the requirement so we can't remember the all Keywords.

we can get these keywords using the help function under the IDLE.


>>> help("keywords")    




Here is a list of the Python keywords.  Enter any keyword to get more help.

False               class               from                or
None                continue            global              pass
True                def                 if                  raise
and                 del                 import              return
as                  elif                in                  try
assert              else                is                  while
async               except              lambda              with
await               finally             nonlocal            yield
break               for                 not




Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top