answersLogoWhite

0

A variable falls under the category of "Python identifier". SUch an identifier must start with a letter (uppercase or lowercase) or an underscore, followed by zero or more letters, underscores, and digits. Note that Python is case-sensitive; for example, myvariable, MyVariable, and MYVARIABLE would be treated as three different variables.

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
More answers

There are no strict rules. Sometimes the first letter of the object represented by the variable is used eg m for mass, v for velocity. At other times, they are sequential letters of the alphabet, such as a, b, c or x, y, z. The variables may be letters from the Greek alphabet; they may be in upper case or lower case.

It is advisable not to use names which may be confused with numbers (depending on your handwriting). For various numbers, possible letters which may cash are:

0 and O

1 and I (upper case i) or l (lower case L)

2 and z

5 and S

6 and b

8 and B

9 and g (not very similar here but consider the letter as it is "normally" written.

User Avatar

Wiki User

8y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What are the rules for naming variables in python?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the naming rules in XML?

XML has no rules like html in regards to tags and naming tags, you write your own xml tags.


Specify the naming convention for variable constant class and method?

The naming convention for variables, constants, classes, and methods involves delimiting separate words with a non-alphanumeric character such as a hyphen or underscore.


Why won't Python open on Windows 8?

Make sure you have the latest version of python downloaded.Run the fileSelect install for all users or install just for me, click NextYou'll see it installs under the C:\Python27 folder, click NextClick Next again for the 'Customize Python' stepClick FinishOpen Control Panel, then SystemClick 'Advanced system settings' on the leftClick the 'Environment Variables' buttonUnder 'System variables' click the variable called 'Path' then the 'Edit...' buttonWithout deleting any other text, add C:\Python27;(include the semi-colon) to the beginning of the 'Variable value' and click OK.Click OK on the 'Environment Variables' window.Restart your computer.Next when you open a command prompt window after the computer restarts and type python you will have python running in the command prompt.


Rules in naming variables in programming?

there are various types of naming rule provide for function ,identifier,i.e variables.but naming rule for variable must meet certain condition.. 1.you can easily idenfy what is variable for.for eg.you may use int a;/to store no of student in your prog. but it is better instead of using "a",you can write any of the following definition int stu; or int stu_no; or int studentno; 2.it must be abbreviated.because although modern compiler support 32 char variable but still where you use that variable you have to type that name again &again. so for eg. in the above case int stu_no; is optimal. when these precondition are met then here are some rules for naming a variable: 1.you use only English alphabet,numeric no,& _(underscore). 2.you must start with a alphabet. then you continue with alphabet or numeric or under score.for eg. you can define a variable like int stu_comp_2009;//for no of student 2009 batch. 3.no variable can start with number or _.such naming may cause some compiler do the right job but maximum would not support this.


What are the rules for naming an array?

The same rules apply to naming arrays as for naming any other identifier (be it a user-defined data type, variables or constants and function names). All identifiers must begin with a non-digit character (see below) and must be unambiguous. Global or external identifiers may be subject to additional restrictions as they have to be processed by other software such as linkers. Non-digit characters: _ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z