Monday, 8 July 2019

Python Identifier


So far we discussed
1.         How to write and execute a python program

Today we are going to discuss the following topics are:

1.         Identifier
2.         Reserved Words

Identifier or User-defined word:

The word defined by the user is called a user-defined word or identifier. Identifier has no meaning.
Identifiers are used for :
Variable names, function names, class names, files, object.

Rules:
1. 1st character must be the alphabet
2. No special characters are allowed
3. No reserved words are used
4. It can be an upper case letter or lower case letter.
5. Identifers are case sensitive

Ex:

A=10
a=20
123abc=10 #error
_123=10 #ok
cash=100 #ok
ca$h=100 #error bcoz $ (special char)
total=100
TOTAL=200
p.v.narasimha.rao=90 #error
p_v=90#ok

Valid
Invalid
Sum123
123sum
FOR=10
for=10

Example:

>>>123abc=10 #SyntaxError: invalid syntax
>>> abc123=10 #OK
>>> print(abc123)

OUTPUT:
10
Next Topic: Reserved word
Previous topic: How to write and execute Python program

You may like the following posts:

Other tutorials
What is Header files (i.e #include<stdio.h>,...) in C/C++ and what is import statement in Java/Python?

1 comment:

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...