Python Diamond Pattern Program #100DaysOfCode Day 16

Day 16 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to print a diamond pattern using stars (*). The goal was to understand nested loops, pattern logic, and spacing techniques in Python. What the program does: • Takes the number of rows as input • Prints the upper half of the diamond • Prints the lower half of the diamond • Uses spaces and stars to create a symmetric pattern How the logic works: 1)A function print_diamond(n) is defined 2)The first for loop prints the upper part of the diamond – Spaces are printed using ' ' * (n - i - 1) – Stars are printed using '*' * (2 * i + 1) 3)The second for loop prints the lower part – It runs in reverse order – The same spacing and star logic is applied Key learnings from Day 16: – Understanding pattern-based logic – Working with nested loops – Controlling spacing and alignment – Strengthening logical thinking #100DaysOfCode #Day16 #Python #PythonProgramming #PatternProgramming #LogicBuilding #CodingPractice #ProblemSolving #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney

  • text

To view or add a comment, sign in

Explore content categories