CoursesCSS StudioExamplesGATECompaniesPrepMentora
Programs/Logic building/Phase 2 - Level 5: Logical Loop Combinations

7 / 12

Next
1. Numbers with Even Digit Sum2. Count Numbers Divisible by 7 but Not 53. All Palindrome Numbers 1-5004. Numbers with Digit Sum Multiple of 35. Smallest & Largest Digit6. Numbers with Even 1s in Binary7. Print i*i Pattern8. Factorial of Each Number 1-N9. Sum of Odd & Even Digits Separately10. Sum with Continue (Skip 0)11. Sum of Squares of Even Numbers12. Count Primes in Range

Phase 2 - Level 5: Logical Loop Combinations

  1. 01Numbers with Even Digit Sum
  2. 02Count Numbers Divisible by 7 but Not 5
  3. 03All Palindrome Numbers 1-500
  4. 04Numbers with Digit Sum Multiple of 3
  5. 05Smallest & Largest Digit
  6. 06Numbers with Even 1s in Binary
  7. 07Print i*i Pattern
  8. 08Factorial of Each Number 1-N
  9. 09Sum of Odd & Even Digits Separately
  10. 10Sum with Continue (Skip 0)
  11. 11Sum of Squares of Even Numbers
  12. 12Count Primes in Range

Print i*i Pattern

Print pattern: 1, 4, 9, 16, ... (i*i).

AdvancedPhase 2 - Level 5: Logical Loop CombinationsExample 7 of 12
print-i-i-pattern.py
1# Take n
2n = int(input("Enter n: "))
3
4# Print i*i pattern
5for i in range(1, n + 1):
6 print(i * i, end=" ")
7print()

Output

Enter n: 5
1 4 9 16 25

What's going on

Print square of each number.

Key Concepts:

Loop from 1 to n
Print i * i for each
Square numbers

🔗Related Content

  • 📖

    Phase 2 - Learn Concepts

    Review Phase 2 concepts and explanations

  • 📝

    Phase 2 - Quiz

    Test your Phase 2 understanding with quiz questions

  • 💻

    Phase 2 - All Practice Problems

    Explore all practice problems for Phase 2

  • 🎓

    Master Your Logic Building - Complete Course

    Browse all phases and tutorials

  • 🧠

    Logic Building Overview

    Learn about the complete logic building curriculum

PreviousNumbers with Even 1s in BinaryNextFactorial of Each Number 1-N

On this page

CodeOutputExplanation
Up nextFactorial of Each Number 1-N
Schoolabe

Learn, Practice, Ace Coding

ExamplesCompaniesTutorialsCSS StudioDSA VisualizersQuizInterview PrepMentoraCareer QuestGATE CS prepGATE CS 2027 study planJob ReadyInternships
AboutContactCareersAffiliate programBlog
DocumentationAPI ReferenceCommunitySupport
Privacy PolicyTermsRefund PolicyCookie Policy

© 2026 Schoolabe