Identifiers
An identifier is a name given to entities like variables,functions,class, functions etc. It helps to differentiate one entity from another.Rules for writing identifiers
1.Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _.
Names like myClass, var_1 and print_this_to_screen, all are valid example.
2.An identifier cannot start with a digit. 1variable is invalid, but variable1 is a valid name.
3.Keywords cannot be used as identifiers.
Eg: global = 1 is invalid
a@=0 is invalid
5.An identifier can be of any length.
- Python is a case-sensitive language. This means, Variable and variable are not the same.
- Always give the identifiers a name that makes sense. While c = 10 is a valid name, writing count=10 would make more sense, and it would be easier to figure out what it represents when you look at your code after a long gap.
- Multiple words can be separated using an underscore, like this_is_a_long_variable.
Variables
A variable can be used to store a certain value or object. In Python, all numbers (and everything else, including functions) are objects. A variable is created through assignment. Their type is assigned dynamically.Eg:
x='binu'
y=23
z=24.5
l=399379379379387983793773973977000102
use type(object) to know the type of the variable object
Eg: type(x) type(y) type(z) type(l)
<type 'str'> <type 'int'> <type 'float'> <type 'long'>
use dir(object) to know the functions associated with the object
Variable can be mutable or immutable. A mutable variable is one whose value may change in place, whereas in an immutable variable change of value will not happen in place.
Keywords are the reserved words in Python.When we create a program, we often like to store values so that it can be used later. We use objects to capture data, which then can be manipulated by computer to provide information. By now we know that object/ variable is a name which refers to a value. It has a type and also store some value.
Variable can be mutable or immutable. A mutable variable is one whose value may change in place, whereas in an immutable variable change of value will not happen in place.
Things to Remember:
- Variables are created when they are first assigned a value.
- Variables type is determined by the value which is assigned.
- Variables must be assigned a value before using them in expression,
- Variables refer to an object and are never declared ahead of time.
Keywords
We cannot use a keyword as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language.
In Python, keywords are case sensitive.
There are 33 keywords in Python 3.7. This number can vary slightly over the course of time.
All the keywords except True, False and None are in lowercase and they must be written as they are. The list of all the keywords is given below.
False | await | else | import | pass |
None | break | except | in | raise |
True | class | finally | is | return |
and | continue | for | lambda | try |
as | def | from | nonlocal | while |
assert | del | global | not | with |
async | elif | if | or | yield |
Simple and Clear. Keep sharing more and more Python online training
ReplyDeletePython training
AWS Online training
AWS training
Dot Net Online Training
Dot Net Training
Download more ktu previous question papers from ktustudents.in
ReplyDeleteThanks for sharing
ReplyDeletePython Online Training In Hyderabad
Python Online Training
Thanks for Share the about Python Courses Concept for Freshers and Experiences,
ReplyDeletePython course in Bangalore
Python Training in Bangalore
Best Python Training Institutes in Bangalore
python training institute in Bangalore
Thanks for sharing this blog this is really nice blog and informative content.
ReplyDeleteOnline Python Course in Hyderabad
Online Machine Learning Course in Hyderabad
Thanks for sharing such informative blog.
ReplyDeleteBecome a Data Science expert with us. study Data Science Course in Hyderabad with Innomatics where you get a great experience and better knowledge.
This post is so interactive and informative.keep updating more information...
ReplyDeletePython Classes in Mumbai
Python Training in Ahmedabad
Python Training in Kochi
Python Training in Trivandrum
Python Training in Kolkata
http://wisdommaterials.com/
ReplyDeletehttps://www.globalcompaniesinfo.com/
http://wisdomallcodes.com
Verde | Shop Premium Accessories: Ties, Cufflinks, Totes & More
ReplyDeleteWelcome to Verde, we are an Indian brand that celebrates the joy of self- expression and embracing your unique style. Explore our consciously crafted selected of accessories, made in India. Looking for the perfect finishing touch to your outfit? We've got you covered! From best-in-class men's ties in classic blue, green, and navy to unique designer cufflinks, including dog designs in silver and gold, we offer a classy selection for every taste. Upgrade your formal wear with our premium neck ties and navy blue coat ties or add a touch of personality with our luxury and unique cufflinks. We also have the perfect gift sets with ties and pocket squares.
HD 404, We Work DLF Forum, Cybercity, Near DLF Cyber Hub, Phase 3, Gurugram, Haryana, 122002
+91 9717222550
contact@verdelife.co