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.

এই তিনটি pattern আয়ত্ত করলে অনেক coding interview প্রশ্ন সহজ হয়ে যায়।

Challenge

+35 XP

n = 4 হলে এই ত্রিভুজ print করুন: * ** *** ****

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