Ainsteinx Logo
Ainsteinx
👤
Welcome to Ainsteinx
Login

Change Language

Currency

Home
Blog
Services
All lessons
EP.3 Python for Laos

if / else: let your program decide

age = 17

if age >= 18:
    print("ລົງທະບຽນໄດ້")
else:
    print("ຍັງນ້ອຍຢູ່")
Video coming soon
EP.3 Basics

if / else: let your program decide

How does a computer make decisions? With if.

if checks a condition: if it is True, the code below it runs; otherwise the else part runs.

Remember two things: end the line with a colon (:), and indent the code inside by 4 spaces.

ep03-if-else.py
age = 17

if age >= 18:
    print("ລົງທະບຽນໄດ້")
else:
    print("ຍັງນ້ອຍຢູ່")

Output

ຍັງນ້ອຍຢູ່
  • #PythonສຳລັບຄົນLaos
  • #Python
  • #ຮຽນໂປຣແກຣມ
  • #ບອກຕໍ່ຄວາມຮູ້
  • #shorts

Watch and share on