What are keywords and identifiers in Python? | Python Basics


What are keywords and identifiers in Python?

    Keywords in Python are basically a reserved word which can’t be used as a variable name, function name or any other identifier. These keywords have a specific purpose in Python and should be used in the way they are intended to. The list of few keywords along with their usages are:

Keyword

Description

and

A logical operator

as

To create an alias

assert

For debugging

break

To break out of a loop

class

To define a class

continue

To continue to the next iteration of a loop

def

To define a function

del

To delete an object

elif

Used in conditional statements, same as else if

else

Used in conditional statements

except

Used with exceptions, what to do when an exception occurs

False

Boolean value, result of comparison operations

finally

Used with exceptions, a block of code that will be executed no matter if there is an exception or not

for

To create a for loop

from

To import specific parts of a module

global

To declare a global variable

if

To make a conditional statement

import

To import a module

in

To check if a value is present in a list, tuple, etc.

is

To test if two variables are equal

lambda

To create an anonymous function

None

Represents a null value

nonlocal

To declare a non-local variable

not

A logical operator

or

A logical operator

pass

A null statement, a statement that will do nothing

raise

To raise an exception

return

To exit a function and return a value

True

Boolean value, result of comparison operations

try

To make a try...except statement

while

To create a while loop

with

Used to simplify exception handling

yield

To end a function, returns a generator


You can find the list of keywords of Python by (see the video below):

    All the keywords except True, False and None are in lowercase and they must be written as they are.

    Identifiers are words that we use to specify or declare variables. Any word that we use as a variable name is called an identifiers. It is important to note that, the identifiers are case sensitive. For example, variable differs from Variable. An identifier usually starts with a letter i.e. from A to Z or from a to z or an underscore (_) followed by letters (alphabets), underscores and digits (0 - 9).

No comments:

Post a Comment

Also read!

Click on any of the below text for additional links:

Class 6

→ Class 6 Computer Kips Solutions
→ Class 6 Gul Mohar English Solutions
→ Class 6 Map Pointing Solutions
→ Class 6 NCERT Civics Solutions
→ Class 6 NCERT Geography Solutions
→ Class 6 NCERT History Solutions
→ Class 6 NCERT Maths Solutions
→ Class 6 NCERT Science Solutions

Class 7

→ Class 7 Computer Kips Solutions
→ Class 7 Gul Mohar English Solutions
→ English Grammar Class 7
→ English Writing Skills Class 7
→ Class 7 Map Pointing Solutions
→ Class 7 NCERT Civics Solutions
→ Class 7 NCERT Civics Notes
→ Class 7 NCERT Civics Extra Questions
→ Class 7 NCERT Geography Solutions
→ Class 7 NCERT Geography Notes
→ Class 7 NCERT Geography Extra Questions
→ Class 7 NCERT History Solutions
→ Class 7 NCERT History Notes
→ Class 7 NCERT History Extra Questions
→ Class 7 NCERT Maths Solutions
→ Class 7 NCERT Science Solutions
→ Class 7 NCERT Science Notes
→ Class 7 NCERT Science Extra Questions

Class 8

→ Class 8 Kips Artificial Intelligence Solutions
→ Class 8 Gul Mohar English Solutions
→ English Grammar Class 8
→ English Writing Skills Class 8
→ Class 8 Map Pointing Solutions
→ Class 8 NCERT Civics Solutions
→ Class 8 NCERT Civics Notes
→ Class 8 NCERT Civics Extra Questions
→ Class 8 NCERT Geography Solutions
→ Class 8 NCERT Geography Notes
→ Class 8 NCERT Geography Extra Questions
→ Class 8 NCERT History Solutions
→ Class 8 NCERT History Notes
→ Class 8 NCERT History Extra Questions
→ Class 8 NCERT Maths Solutions
→ Class 8 NCERT Science Solutions
→ Class 8 NCERT Science Notes
→ Class 8 NCERT Science Extra Questions
→ Class 8 NCERT Science Exemplar
→ Class 8 NCERT Science MCQs

Class 9

→ Class 9 Kips Artificial Intelligence Solutions
→ Class 9 Map Pointing Solutions
→ Class 9 NCERT Civics Solutions
→ Class 9 NCERT Geography Solutions
→ Class 9 NCERT History Solutions
→ Class 9 NCERT Maths Solutions
→ Class 9 NCERT Science Solutions

Class 10

→ Class 10 Kips Artificial Intelligence Solutions
→ Class 10 NCERT English Solutions
→ Class 10 Map Pointing Solutions
→ Class 10 NCERT Civics Solutions
→ Class 10 NCERT Civics Notes
→ Class 10 NCERT Civics Extra Questions
→ Class 10 NCERT Geography Solutions
→ Class 10 NCERT Geography Notes
→ Class 10 NCERT Geography Extra Questions
→ Class 10 NCERT History Solutions
→ Class 10 NCERT History Notes
→ Class 10 NCERT History Extra Questions
→ Class 10 NCERT Maths Solutions
→ Class 10 NCERT Science Solutions
→ Class 10 NCERT Science Notes
→ Class 10 NCERT Science Extra Questions

Computer Languages

→ Python Basics

Extra Activities

→ Extra Activities

Extra Knowledge

→ Extra Information
→ General Knowledge
→ Historical Places in India
→ Latest technology
→ Physical Sciences
→ Facts

• Mathematics quick links
→ Mathematical Terms
→ Maths Tricks

Home Top