Computer Science, asked by CrizMack23261, 7 months ago

Write five valid identifiers in python

Answers

Answered by Equestriadash
9

Identifiers are unique names given to a variable.

  • They identify the name of a entity when asked.
  • Can consist of letters, numbers and underscores; no other special character can be used.
  • They aren't case sensitive.
  • They can't start with a number.

Examples:

  • XID,
  • high_score,
  • bot,
  • rate_name
  • _error

Invalid identifiers would include:

  • Price*qty

As it has a special character (*).

  • 4thcol

As it starts with a number.

  • for

As it is a keyword. Keywords cannot be used as identifiers.

  • %rate

As it has a special character (%).

  • in

As it is a keyword.


EliteSoul: Nice :clapping:
Equestriadash: Thank you! ^_^"
VishalSharma01: ShanDaar :)
Equestriadash: Thank you! ^_^"
Answered by Anonymous
9

\large{\underline{\underline{\sf Identifiers \ In \ Python \colon }}}

  • Identifiers are generally defined as combination of lowercase alphabets,numericals and underscore.

  • Some identifiers are pre defined and pre recognised by the system are termed as Keywords. There are around 33 Keywords. Some of them are listed below.

List of some keywords are as follows :

\begin{array}{|c|}\cline{1-1} \sf Keywords \\ \cline{1-1} \sf True \\ \cline{1-1} \sf False \\ \cline{1-1} \sf None \\ \cline{1-1} \sf and \\ \cline{1-1} \sf or \\ \cline{1-1} \end{array}

For example, (Refer to the attachment)

There are some rules to be assigned while naming an identifier :

  • The first character in the identifier should be non - numeral.
  • Any special character in the identifier would render a syntax error in the code.
  • Keywords can't be used as Identifiers.
  • Identifiers can start with an underscore or alphabets.

For example,

1. my_name,my_number etc would be valid Identifiers

2. @name or #me would render syntax errors

3. 4_ever would cause an error while _4ever is valid.

Attachments:

VishalSharma01: BahutKhub :)
EliteSoul: Great :blob_claps:
Similar questions