Keywords in Python
Below is the list of keywords in Python:
False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield
Example:
# def, for, if, in, return, continue keyword
def find_even_number(numbers):
for number in numbers:
if number % 2 == 0:
return number
else:
continue
return None
# Example usage
numbers = [1, 3, 5, 4, 2, 8]
even_number = find_even_number(numbers)
if even_number is not None:
print(f"First even number: {even_number}")
else:
print("No even number found in the list.")
# True, False keyword
is_sunny = True
is_raining = False
# Pass keyword
if is_sunny:
print("Let's go outside!")
else:
pass # Do nothing in this case (placeholder)
if is_raining:
print("Bring an umbrella!")
Output
First even number: 4 Let's go outside!
What is Keyword in Programming?
Keywords are predefined or reserved words that have special meaning to the compiler. In this article, we will discuss about keywords in programming, its importance, and usage in different languages.
Contact Us