Lazy Programming Series

Lazy Programming Series – Challenge – 3

Challenge – 3

Problem Statement:

Develop a Python program that generates a pattern of stars based on user input. The program should prompt the user to input the number of lines (a) and a boolean value (b). The boolean value indicates whether the pattern should be printed in ascending order (True) or descending order (False).

The program should define a function star(a, b) that takes the number of lines (a) and the boolean value (b) as parameters. Inside this function, it should print a pattern of stars based on the specified conditions. If b is True, the pattern should be printed in ascending order, starting from one star in the first line and increasing by one star in each subsequent line, up to a lines. If b is False, the pattern should be printed in descending order, starting from a stars in the first line and decreasing by one star in each subsequent line, down to one star.

The program should then call the star() function with the user-provided inputs to generate and display the desired star pattern.

Input:

  • a: An integer representing the number of lines for the star pattern.
  • b: A boolean value (0 or 1) indicating whether to print the pattern in ascending order (True) or descending order (False).

Output:

  • The program should output the star pattern based on the provided inputs.

Constraints:

  • a will be a positive integer.
  • b will be either 0 or 1.
  • The star pattern should be printed according to the specified conditions.
Hi, I’m saksham dixit

Leave a Reply

Your email address will not be published. Required fields are marked *