Question :

What are the rules for naming a variable?

Subject

Python Python

Standard

Computer Science Engineering Computer Science Engineering

Views

750

Asked By

Deepak

Anik
Answer / Solution

Variable naming conventions:

  • Variable names are case sensitive. For e.g. num and NUM are treated as two different variables.
  • Keywords or words with special meaning, should not be used as the variable names.
  • Variable names should be short and meaningful.
  • All variable names must begin with a letter or an underscore.
  • After the first initial letter, variable names may contain letters and digits (0 to 9) and an underscore (_) but no spaces or special characters are allowed.
  • Examples of valid variable names: last_name, name, name1, _name
  • Examples of invalid variable names: last-name, 9marks, marks%
Question :

What are the rules for naming a variable?

Subject

Python Python

Standard

Computer Science Engineering Computer Science Engineering

Views

750

Asked By

Emily

Anik
Answer / Solution

Variable naming conventions:

  • Variable names are case sensitive. For e.g. num and NUM are treated as two different variables.
  • Keywords or words with special meaning, should not be used as the variable names.
  • Variable names should be short and meaningful.
  • All variable names must begin with a letter or an underscore.
  • After the first initial letter, variable names may contain letters and digits (0 to 9) and an underscore (_) but no spaces or special characters are allowed.
  • Examples of valid variable names: last_name, name, name1, _name
  • Examples of invalid variable names: last-name, 9marks, marks%

Top Trending Questions


Recent Question Update

Connect python to mysql database
looping structure in python
What are the different arithmetic operators used in Python and its precedence of operators?
Write any four features of Python.
What do you understand by Typecasting in Python with the help of examples?
What is the role of indentation in Python
Explain IDLE and its main purpose.
Which are the applications of Python?
What is the difference between interactive mode and script mode in Python?

Advantages Of NCERT, CBSE & State Boards Solutions For All Subjects

  • All the NCERT Solutions have been prepared by academic experts having 10+ years of teaching experience.
  • They have prepared all the solutions in simple and easy language so that each and every student can understand the concepts easily.
  • All the solutions have been explained step to step-wise in details with better explanations.
  • Students can also use these question and answers for your assignments and in homework help.
  • All the solutions have been explained in detail and the answers have been compiled in a step-wise manner.
  • All the questions and answers are commonly prepared according to the Latest Syllabus of Board Education and Guidelines.
  • Students can know about the various types of questions asked in the exams with the help of these solutions.

Top Course Categories