Comparison and Logical Operators
Learn how to compare values and combine conditions.
Learn by experimenting
Study the Python code, run it, change values and observe the output. Practical experimentation is an important part of learning programming.
Python Code
Python runs directly in your browser.
age = 20
has_id = True
if age >= 18 and has_id:
print('Access allowed')
else:
print('Access denied')
Python Output
Program output appears here.
Test your understanding
Choose the best answer.
Which keyword is used to define a function in Python?