How to print Hollow Diamond Shaped star "*" pattern using Python | python tutorial for beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ธ.ค. 2024

ความคิดเห็น • 14

  • @TycomacCodes
    @TycomacCodes  3 ปีที่แล้ว +2

    7 Hours course Python for pattern programs, Example Programs, Data Structures and Algorithms (3 in 1 course) out now link : www.udemy.com/course/python-for-patterns-problems-data-structures-algorithms/?referralCode=186515267189E391E366

  • @TycomacCodes
    @TycomacCodes  4 ปีที่แล้ว +3

    If you like this to type of content then consider subscribing, it really helps out the channel
    Find more pattern programs here:
    th-cam.com/play/PLhBd9eXZZqGIhrPl97yOfOAI7TqJQOHRm.html

  • @williamjayaraj2244
    @williamjayaraj2244 2 ปีที่แล้ว

    Thank you for this lesson on creating diamond pattern in an easily understandable method.

  • @yashilrajbeesetty6628
    @yashilrajbeesetty6628 3 ปีที่แล้ว

    Ur video helped me, can't say how much😌

  • @THE_KODER
    @THE_KODER 3 ปีที่แล้ว

    Awesome bro

  • @gurvirsandhu8644
    @gurvirsandhu8644 4 ปีที่แล้ว

    What if you want the rows and columns to be n, not 7?
    Please answer

    • @frd334
      @frd334 3 ปีที่แล้ว +1

      Take if condition as below,but it will work for only odd numbers such 3,5,7,9,11 ...:
      n = int(input())
      for row in range(1,n+1):
      for col in range(1,n+1):
      if (row+col==(n+1)/2+1) or (col-row==(n+1)/2-1) or (row-col==(n+1)/2-1) or (col+row==n+(n+1)/2):
      print('*',end='')
      else:
      print(' ',end='')
      print()

    • @DemonExplainer01
      @DemonExplainer01 2 ปีที่แล้ว

      n=int(input("enter row"))
      for i in range(1,n+1):
      print(' '*(n-i)+'*',end="")
      if i>=2:
      print(' '*(2*i-3)+'*',end="")
      print()
      for i in range(1,n):
      print(' '*(i)+'*',end="")
      if i

    • @07_crew_officials
      @07_crew_officials 2 ปีที่แล้ว

      Its not exactly giving the correct pattern their is a issue in output can u plz check nd provide the correct one...

  • @keremoztopuz875
    @keremoztopuz875 2 ปีที่แล้ว +1

    hello sir, i did exactly what u did but my output is this:
    b
    b
    b
    b
    b
    b
    b
    b
    b
    b
    b
    b

  • @Remo123
    @Remo123 2 ปีที่แล้ว

    😘

  • @anshulkumar8195
    @anshulkumar8195 2 ปีที่แล้ว

    not true for all cases

    • @mohankadagala59
      @mohankadagala59 2 ปีที่แล้ว

      Its a customized code and is not valid for other inputs if you provide

    • @ganeshjadhav566
      @ganeshjadhav566 8 หลายเดือนก่อน

      # hollow diamond
      n = int(input("Enter number of rows :: "))
      def hollow_diamond(n):
      for i in range((n*2)-1):
      for j in range((n*2)-1):
      if (i+j == n-1) or (i-j == n-1) or(j-i == n-1) or (i+j == 3*(n-1)):
      print(" *",end="")
      else:
      print(" ",end="")
      print("")
      hollow_diamond(n)
      this code generate accurate output for any inputs (in numbers)