🐍 Python Assignment 5 – Loops & Pattern Programming
A collection of beginner-to-intermediate Python programs focused on mastering loops, nested loops, pattern printing, functions, string manipulation, and algorithmic thinking.
This assignment emphasizes understanding the logic behind iteration, rather than simply memorizing syntax. Every problem is implemented using appropriate looping techniques (for and while) and demonstrates multiple approaches wherever applicable.
This repository contains solutions to fundamental Python programming exercises covering:
- Loop control (for & while)
- Nested loops
- Star pattern printing
- Functions
- Mathematical algorithms
- String processing
- Basic problem-solving techniques
The goal of this assignment is to build a strong foundation in iteration and develop logical thinking required for Data Structures & Algorithms, Automation, Data Analysis, and Software Development.
- Print output on the same line
- end="" parameter
- while loop fundamentals
- for loop fundamentals
- Using for loop
- Using nested loops
- Using for loop
- Using nested loops
Pyramid (Normal Triangle)
- Using string multiplication
- Using nested loops
- Space and star alignment logic
- Using for loop
- Using while loop
- Using for loop
- Using reverse while loop
- Using for loop
- Using while loop
- Handling uppercase and lowercase characters
Longest Word in a Sentence
- Using split()
- Comparing word lengths
- First N Fibonacci numbers
- Using for loop
- Using while loop
- Understanding variable shifting (a, b, next_num)
Assignment-5/
│
├── Loop Basics
│ ├── Same Line Output (while)
│
├── Pattern Printing
│ ├── Right Triangle
│ ├── Reverse Right Triangle
│ ├── Pyramid
│ ├── Nested Loop Patterns
│
├── Factorial
│ ├── With Function
│ ├── Without Function
│ ├── For Loop
│ └── While Loop
│
├── String Programs
│ ├── Count Vowels
│ └── Longest Word
│
└── Fibonacci Series
├── For Loop
└── While Loop
- for loops
- while loops
- Nested loops
- Loop counters
- Conditional statements (if, else)
- String indexing
- String methods
- split()
- len()
- Functions
- Return statements
- Variable updates
- Pattern logic
- Mathematical algorithms
After completing this assignment, you will be able to:
- Understand the difference between for and while loops.
- Solve pattern-printing problems using nested loops.
- Build mathematical algorithms using iteration.
- Traverse strings efficiently.
- Write reusable functions.
- Apply logical thinking to programming problems.
- Strengthen problem-solving skills for coding interviews.
- Print numbers in the same line
- Right triangle pattern
- Reverse triangle pattern
- Pyramid pattern
- Factorial using loops
- Factorial using functions
- Count vowels in a string
- Find the longest word in a sentence
- Generate Fibonacci sequence
- Python Fundamentals
- Iteration
- Nested Iteration
- Pattern Programming
- String Processing
- Algorithm Design
- Logical Thinking
- Clean Code Practices
Ankit Rai
Aspiring SQL Developer | Data Analyst
Currently learning:
- Python
- SQL
- Power BI
- Excel
- Data Analytics
⭐ If you found this repository useful, consider giving it a Star.