0

How Can I make a program that print pattern with the help of boolean variable as input()?

Pattern printing with the help of for loop

20th Feb 2022, 5:02 PM
Abdul Hadi Salman
Abdul Hadi Salman - avatar
7 Answers
+ 1
Try this modify it n = int(input()) m = n >= 0 for i in range((not m) * n, m * n): print(abs(i) * '*')
20th Feb 2022, 5:37 PM
Мартин 😑🎵
Мартин 😑🎵 - avatar
+ 1
What kind of pattern? n = int(input()) for i in range(0, n): print(i * '*')
20th Feb 2022, 5:08 PM
Мартин 😑🎵
Мартин 😑🎵 - avatar
0
* ** *** **** *****
20th Feb 2022, 5:09 PM
Abdul Hadi Salman
Abdul Hadi Salman - avatar
0
This type if input is true
20th Feb 2022, 5:09 PM
Abdul Hadi Salman
Abdul Hadi Salman - avatar
0
***** **** *** ** * This if input is false
20th Feb 2022, 5:09 PM
Abdul Hadi Salman
Abdul Hadi Salman - avatar
0
def pattern( grow = True, rows = 5 ): stars = 1 if grow else rows for i in range( rows ): print( '* ' * stars ) stars = stars +1 if grow else stars - 1 print() # input 0 for false, non-zero number for true pattern( bool( int( input() ) ) )
20th Feb 2022, 6:23 PM
Ipang