Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Keywords in Python programming language

Posted on September 15, 2019January 25, 2020

Table of Contents

  • Keywords in Python programming language
    • Keywords are the reserved words in python
      • 5. class –  Python is an object-oriented programming language, 

Keywords in Python programming language

In this tutorial, we will discuss the Keywords in Python programming language

Keywords are the reserved words in python

Keywords are reserved words in python. We can not use a keyword as a variable name, function name or any other identifier language.

1. and – and is a logical operator in python. Only if “and” and “if” operands are true, the result will be true. Otherwise, if one operand becomes false, the result will be false. If both operands are false, the return would be false.

The truth table of and keyword

Example of usage of and keyword

2. as – as is used to when we want to give a module a different(user define) alias

3. assert – 

4. break – break keyword is used inside of whileloop and forloop

Example for break

5. class –  Python is an object-oriented programming language, 

We can define our own class or user-defined class using the class keyword.

Defining a class in Python is simple. A python class can consist a lof collection of related properties or attributes and methods
Class can be defined anywhere in python. But it is a good practice to define a single class in a module.

Syntex of class in python

6. continue –  continue keyword is used  inside of whileloop and forloop

7. def – def is used to define a user-defined function. A function is a group of related statements for one or more specific task

8. del – del is used to delete or remove a target element in python. del is used to delete variables, list or dictionary elements.
The del statements look like this

Object means a type of python object. Usually, these are variables but they can be functions, list dictionaries

9. elif – elif is a keyword in python similar elseif in other languages. It is used for conditional statements and test conditions. The colon(:) at the end of the statement is required.

Output

x is less than  y

10. else – Elif is a keyword in python, it is used in conditional statements and test conditions. The colon(:) at the end of the statement required

Output

x is equal to y

11. except

12. finally

13. for – for is a keyword in Python, for looping statement. It is used to limit the number of times we want to execute.

Output
Hello sankar
Hello kanthan
Hello rajah
Hello yogan
Hello kumar

14. from

15. false – This keyword is used to represent a boolean false value. when become a statement is false “false” is  displayed

Example 1

Example 2

16. global

17. if is used in conditional statements and test conditions. The colon(:) at the end of the statement required

Output

x is greater than to y

18. import

19. in – in is used to check if the element contains a list or tuple etc….
It returns true if the value is present, it returns false if the value is not present.

another used in the forloop at python

 
Output
H

a
p
p
y

b
i
r
t
h
d
a
y

20. is

21. lambda

22. nonlocal

23. not –  not operator is used to invert the true value

Example not

24. or –  or operator will turn into true if any of the operands are true

Example for or
 

25. pass – pass is a keyword used to require implementation. pass is a null operation- noting happens when it executes.

Syntex

 

26. raise

27. return

28. try

29. true – This keyword is used to represent a boolean true value. When a statement is true, the word “true” is displayed.

Example

28. while – while is a keyword for looping statement. It is used to limit the number of times we want to execute

 
Output
 10

9
8
7
6
5
4
3
2
1

Learn more about python click Python while loop and Nested while loop in Python

29. with

30. yeild

 

Suggested for you

Keyword in C language

Data type in Pyton language

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes