coding180 icon
Coding180
4 - Python Keywords

4 - Python Keywords

Home > Tutorials > Python for beginners > Getting started with Python


In Python, keywords are specific words that have a special meaning in the language. For example, the keyword def is used to define a function, and the keyword for is used to create a for loop to iterate over a sequence of values.

There are approximately 33 keywords in Python, and they cannot be used as variable names because they are reserved for specific purposes in the language.

Here is a list of some common Python keywords:

  • and
  • as
  • assert
  • break
  • class
  • continue
  • def
  • del
  • elif
  • else
  • except
  • False
  • finally
  • for
  • from
  • global
  • if
  • import
  • in
  • is
  • lambda
  • None
  • nonlocal
  • not
  • or
  • pass
  • raise
  • return
  • True
  • try
  • while
  • with
  • yield

Quiz

 

  1. What is the keyword used to define a function in Python?

    1. A. def

    2. B. function

    3. C. lambda

    4. D. try

  2. What is the keyword used to create a for loop in Python?

    1. A. for

    2. B. loop

    3. C. iterate

    4. D. while

  3. What is the keyword used to specify an exception handler in a try-except block in Python?

    1. A. else

    2. B. finally

    3. C. except

    4. D. raise

  4. What is the keyword used to indicate the end of a loop in Python?

    1. A. break

    2. B. continue

    3. C. return

    4. D. pass

  5. What is the keyword used to import a module or package in Python?

    1. A. import

    2. B. from

    3. C. global

    4. D. nonlocal


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel