Python programming language
Python is a high-level, interpreted, and general-purpose programming language that is used for a wide
range of applications such as web development, scientific computing, data analysis, artificial intelligence,
and more. It was created by Guido van Rossum in the late 1980s and was first released in 1991.
Keywords-
Keywords in Python are the reserved words that have a predefined meaning and cannot be used as
variable names, function names or any other identifiers. Here is the list of all the keywords in Python:
and del from None True
as elif global nonlocal try
assert else if not while
break except import or with
class False in pass yield
continue finally is raise async
def for lambda return await
It's important to note that keywords are case-sensitive in Python, which means that 'True' and 'true' are
not the same thing, and only the first one is a keyword.
Rules for writing keywords in python programming language-
1. Keywords are always written in lowercase letters.
2. Keywords cannot be used as variable names, function names, or any other identifiers.
3. Keywords cannot be abbreviated or used in any other form.
4. There are 33 keywords in Python, and they have a predefined meaning.
5. Keywords cannot be used for any other purpose other than their predefined use in Python.
Identifiers-
In Python programming language, an identifier is a name given to a variable, function, class, module, or
other objects. It is used to identify the object and access it in the program. Identifiers in Python have the
following rules:
1. Identifiers must begin with a letter (either uppercase or lowercase) or an underscore (_).
2. Identifiers can contain letters (uppercase or lowercase), digits (0-9), or underscores (_).
3. Identifiers are case-sensitive, which means that my_variable and My_Variable are different
identifiers.
4. Identifiers cannot be a keyword or reserved word. For example, 'if', 'else', 'for', 'while', etc. are
reserved words in Python and cannot be used as identifiers.
, 5. Identifiers should be descriptive and meaningful, so that they can be easily understood and
maintained by other developers.
Here are some examples of valid and invalid identifiers in Python:
Valid Identifiers:
• my_variable
• MyVariable
• _my_variable
• myVariable123
Invalid Identifiers:
• 123myvariable (cannot start with a digit)
• if (reserved word in Python)
• my-variable (cannot use hyphen in an identifier)
Statements-
In Python programming language, a statement is a unit of code that performs an action, such as
assigning a value to a variable, calling a function, or looping over a sequence of values. Python supports
a variety of statements, including:
1. Assignment statements: These statements assign a value to a variable using the assignment
operator (=). For example, x = 10 assigns the value 10 to the variable x.
2. Conditional statements: These statements execute different code depending on whether a
condition is true or false. The most common conditional statement in Python is the if statement.
For example:
if x > 0:
print("x is positive")
else:
print("x is non-positive")
3. Loop statements: These statements execute a block of code repeatedly, either a fixed number of
times or until a certain condition is met. Python supports two main types of loop statements: for
loops and while loops. For example:
for i in range(10):
print(i)
while x < 10:
x=x+1
Python is a high-level, interpreted, and general-purpose programming language that is used for a wide
range of applications such as web development, scientific computing, data analysis, artificial intelligence,
and more. It was created by Guido van Rossum in the late 1980s and was first released in 1991.
Keywords-
Keywords in Python are the reserved words that have a predefined meaning and cannot be used as
variable names, function names or any other identifiers. Here is the list of all the keywords in Python:
and del from None True
as elif global nonlocal try
assert else if not while
break except import or with
class False in pass yield
continue finally is raise async
def for lambda return await
It's important to note that keywords are case-sensitive in Python, which means that 'True' and 'true' are
not the same thing, and only the first one is a keyword.
Rules for writing keywords in python programming language-
1. Keywords are always written in lowercase letters.
2. Keywords cannot be used as variable names, function names, or any other identifiers.
3. Keywords cannot be abbreviated or used in any other form.
4. There are 33 keywords in Python, and they have a predefined meaning.
5. Keywords cannot be used for any other purpose other than their predefined use in Python.
Identifiers-
In Python programming language, an identifier is a name given to a variable, function, class, module, or
other objects. It is used to identify the object and access it in the program. Identifiers in Python have the
following rules:
1. Identifiers must begin with a letter (either uppercase or lowercase) or an underscore (_).
2. Identifiers can contain letters (uppercase or lowercase), digits (0-9), or underscores (_).
3. Identifiers are case-sensitive, which means that my_variable and My_Variable are different
identifiers.
4. Identifiers cannot be a keyword or reserved word. For example, 'if', 'else', 'for', 'while', etc. are
reserved words in Python and cannot be used as identifiers.
, 5. Identifiers should be descriptive and meaningful, so that they can be easily understood and
maintained by other developers.
Here are some examples of valid and invalid identifiers in Python:
Valid Identifiers:
• my_variable
• MyVariable
• _my_variable
• myVariable123
Invalid Identifiers:
• 123myvariable (cannot start with a digit)
• if (reserved word in Python)
• my-variable (cannot use hyphen in an identifier)
Statements-
In Python programming language, a statement is a unit of code that performs an action, such as
assigning a value to a variable, calling a function, or looping over a sequence of values. Python supports
a variety of statements, including:
1. Assignment statements: These statements assign a value to a variable using the assignment
operator (=). For example, x = 10 assigns the value 10 to the variable x.
2. Conditional statements: These statements execute different code depending on whether a
condition is true or false. The most common conditional statement in Python is the if statement.
For example:
if x > 0:
print("x is positive")
else:
print("x is non-positive")
3. Loop statements: These statements execute a block of code repeatedly, either a fixed number of
times or until a certain condition is met. Python supports two main types of loop statements: for
loops and while loops. For example:
for i in range(10):
print(i)
while x < 10:
x=x+1