Lệnh if trong Python
<Python>Bài 6: If , elif trong Python.
Tạo file: bai6.py
people = 20 #gán giá trị cho biến cats = 30 dogs = 15 if people < cats: print "Too many cats! The world is doomed!" elif people > cats: print "Not many cats! The world is saved!" else: print "people equal cats" if people > dogs: print "The world is dry!" dogs += 5 # dogs = dogs + 5 if people > dogs: print "People are greater than to dogs." elif people < dogs: print "People are less than to dogs." else: print "People are dogs."
Kết quả:
Chúc các bạn thành công!
No Comment to " Lệnh if trong Python "