๐งช ็ๆๅจ
โฑ๏ธ 25-30 min๐ Advanced
main.py
Costs 1 credit
ๅ ่ฝฝ็ผ่พๅจไธญ...
่พๅบ Outputๆง่กๆๅ
[้่ฏฏๆ็คบ] ๆฃๆตๅฐไธญๆๅ จ่ง็ฌฆๅท๏ผๅฆ ๏ผ ๏ผ ๏ผ ๏ผ ๏ผ๏ผ๏ผPython ่ฏญๆณๅฏ่ฝๆ ๆณ่งฃๆใ ่ฏทๆนๆ่ฑๆๅ่ง็ฌฆๅท๏ผ( ) , : ;
Terminal (Simulated)Install commands are simulated only, no real network requests
$
Step 1: ็ฌฌไธไธช็ๆๅจ
็ๆๅจๅฝๆฐ็จ yield ๆ้ไบงๅบๆฐๆฎ๏ผ่ไธๆฏไธๆฌกๆงๅ
จ้จ่ฟๅใ
ๅบๅฑ้ป่พ๏ผ
ๆฏๆฌก้ๅฐ
่ฟๅฐฑๆฏๆฐๆงๆฑๅผ็ๆ ธๅฟๆบๅถใ
ๆฏๆฌก้ๅฐ
yield ไผโๆๅๅนถ่ฟๅไธไธชๅผโ๏ผไธๆฌก่ฟญไปฃไปๆๅ็น็ปง็ปญๆง่กใ่ฟๅฐฑๆฏๆฐๆงๆฑๅผ็ๆ ธๅฟๆบๅถใ
ไฝ ็ไปปๅก๏ผ
- ๅๅปบ็ๆๅจๅฝๆฐ
count_up_to(n) - ไป 1 yield ๅฐ n
- ็จ for ๅพช็ฏ้ๅ
count_up_to(5)ๅนถ่พๅบๆฏไธชๅผ
Self-Check List
- ๅๅปบๅบๆฌ็ๆๅจ
Transfer Template
def count_up_to(n):
for i in range(1, n + 1):After completing this step, you should be able to independently explain and reproduce this concept, then apply it to similar problems.