top of page

Naming Rules in Python

  • Writer: Jino Shaji
    Jino Shaji
  • Jan 7, 2015
  • 1 min read

Updated: Jun 9, 2020


•Names are case sensitive and cannot start with a number.  They can contain letters, numbers, and underscores.

 bob  Bob  _bob  _2_bob_  bob_2  BoB


•There are some reserved words:

and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while


Accessing Non-existent Name

•If you try to access a name before it’s been properly 

created (by placing it on the left side of an assignment), 

you’ll get an error. 

>>> y

Traceback (most recent call last):

  File “”, line 1, in -toplevel-

    y

NameError: name ‘y’ is not defined

>>> y = 3

>>> y

3


Recent Posts

See All
Program to Create an investment report.

“””Program: investment.py Author: JINO SHAJI Compute an investment report. 1. The inputs are        starting investment amount       ...

 
 
 

Comments


bottom of page