ທຸກບົດຮຽນ
ep04-for-loop.py
EP.4
Python ສຳລັບຄົນ Laos
for loops: repeat without retyping
for i in range(1, 6):
print("ຮອບທີ", i)
Video coming soon
EP.4
ພື້ນຖານ
for loops: repeat without retyping
Count from 1 to 5 with a single line of logic.
for ໃຊ້ເຮັດວຽກຊ້ຳຫຼາຍເທື່ອ. range(1, 6) ໃຫ້ຕົວເລກ 1, 2, 3, 4, 5 (ບໍ່ລວມ 6).
ແຕ່ລະຮອບ ຕົວແປ i ຈະປ່ຽນເປັນຕົວເລກຖັດໄປ.
for i in range(1, 6):
print("ຮອບທີ", i)
ຜົນລັບ
ຮອບທີ 1 ຮອບທີ 2 ຮອບທີ 3 ຮອບທີ 4 ຮອບທີ 5
- #PythonສຳລັບຄົນLaos
- #Python
- #ຮຽນໂປຣແກຣມ
- #ບອກຕໍ່ຄວາມຮູ້
- #shorts
Watch and share on
ຮຽນຕໍ່
EP.1
Python ສຳລັບຄົນ Laos
Your first program: print()
print("ສະບາຍດີ ລາວ!")
print("ຂ້ອຍກຳລັງຮຽນ Python")
EP.1
ພື້ນຖານ
Your first program: print()
Write your first program in a single line!
EP.2
Python ສຳລັບຄົນ Laos
Variables: boxes for your data
name = "ສົມພອນ"
age = 20
height = 1.68
print(name, age, height)
EP.2
ພື້ນຖານ
Variables: boxes for your data
A variable is a labelled box that can hold anything.
EP.3
Python ສຳລັບຄົນ Laos
if / else: let your program decide
age = 17
if age >= 18:
print("ລົງທະບຽນໄດ້")
else:
print("ຍັງນ້ອຍຢູ່")
EP.3
ພື້ນຖານ
if / else: let your program decide
How does a computer make decisions? With if.
EP.5
Python ສຳລັບຄົນ Laos
Lists: many things in one place
cities = ["ວຽງຈັນ", "ຫຼວງພະບາງ", "ປາກເຊ"]
cities.append("ສະຫວັນນະເຂດ")
print(cities[0])
print(len(cities))
EP.5
ຂໍ້ມູນ ແລະ ໂຄງສ້າງ
Lists: many things in one place
Can one variable hold many items? Yes, with a list.