Lesson 15 of 34

Loop Patterns: തുകകൾ, എണ്ണങ്ങൾ, രൂപങ്ങൾ

10 min 35 XP

Pattern 1, accumulator: loop-ന് മുമ്പ് total = 0 വെച്ച് ഓരോ round-ലും അതിലേക്ക് കൂട്ടൂ.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Pattern 2, counter: condition true ആകുമ്പോൾ മാത്രം count-ൽ 1 കൂട്ടൂ.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Pattern 3, രൂപങ്ങൾ: "*" * 3 നൽകുന്നു "***". Loop-നൊപ്പം ചേർത്ത് രൂപങ്ങൾ വരയ്ക്കൂ.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

ഈ മൂന്ന് patterns പഠിച്ചാൽ പല coding interview ചോദ്യങ്ങളും എളുപ്പമാകും.

Challenge

+35 XP

n = 4 ആകുമ്പോൾ ഈ ത്രികോണം print ചെയ്യൂ: * ** *** ****

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.