Lesson 15 of 34

Loop Patterns: మొత్తాలు, లెక్కలు, ఆకారాలు

10 min 35 XP

Pattern 1, accumulator: loop కి ముందు total = 0 పెట్టి, ప్రతి రౌండ్‌లో దానికి కలపండి.

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: షరతు నిజమైనప్పుడు మాత్రమే 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 ఇంటర్వ్యూ ప్రశ్నలు సులభమవుతాయి.

Challenge

+35 XP

n = 4 తో ఈ త్రిభుజాన్ని print చేయండి: * ** *** ****

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