Python Exercise 4: Astrologer's Stars

Code file as described in the video

# Exercise 4
# Pattern Printing
# Input = Integer n
# Boolean = True or False
#
# True n=5
# *
# **
# ***
# ****
#
# False n=5
# ****
# ***
# **
# *
  


Comments(5)

charzo at 2019-06-23 09:30:09 says
print("Please enter the number of row(s) you want to print ") given_row=int(input()) print("Enter 'Yes' for Top to Bottom and 'No' for Bottom to top style") print_style=input().lower() #If we typecast any string to Boolean , it will be always "True", so typecasting an input() to boolean is difficult I found. if print_style=='yes' : print_style=1 elif print_style=='no': print_style = 0 else: print("Invalid Input") def top_to_bottom(row_num): row_flag=1 while(row_flag<=row_num): print_flag = 1 while(print_flag<=row_flag): print(" * ",end="") print_flag=print_flag+1 row_flag=row_flag+1 print("\n") def bottom_to_top(row_num): row_flag=1 while(row_flag<=row_num): print_flag = 5 while(print_flag>=row_flag): print(" * ",end="") print_flag=print_flag-1 row_flag=row_flag+1 print("\n") if(print_style): top_to_bottom(given_row) else: bottom_to_top(given_row)
charzo at 2019-06-23 09:30:09 says
Ignore it
charzo at 2019-06-23 09:30:09 says
I am trying to paste the code here , but it is getting messed up!!
Manav_Seng at 2019-06-23 09:30:09 says
Name: Manav Sengupta Solution: #Code with harry Exercise 4-- Astrologer's stars try: while(True): N = int(input("Enter the no. of rows of stars you want")) bools = bool(int(input("Enter 1 or 0 for (Upright) or (Inverted) respectively"))) if(bools): i=1 r=1 while (i<=N): print(i * "*") i = i + r temp = int(input("Enter 1 to Continue else enter anything else")) if (temp == 1): continue else: break else: i=N r=-1 while (i>=1): print(i * "*") i = i + r temp = int(input("Enter 1 to Continue else enter anything else")) if (temp == 1): continue else: break except: print("Sorry Unexpected Error!") print(147*"*"+"\n*"+145*" "+"*\n*"+9*" "+"Thanks for checking out my code, and a ton of thanks to CodewithHarry Channel for all the Quality Content for Free"+22*" "+"*\n*"+145*" "+"*\n"+147*"*") # Gratitude
Manav_Seng at 2019-06-23 09:30:09 says
Name: Manav Sengupta Solution: #Code with harry Exercise 4-- Astrologer's stars try: while(True): N = int(input("Enter the no. of rows of stars you want")) bools = bool(int(input("Enter 1 or 0 for (Upright) or (Inverted) respectively"))) if(bools): i=1 r=1 while (i<=N): print(i * "*") i = i + r temp = int(input("Enter 1 to Continue else enter anything else")) if (temp == 1): continue else: break else: i=N r=-1 while (i>=1): print(i * "*") i = i + r temp = int(input("Enter 1 to Continue else enter anything else")) if (temp == 1): continue else: break except: print("Sorry Unexpected Error!") print(147*"*"+"\n*"+145*" "+"*\n*"+9*" "+"Thanks for checking out my code, and a ton of thanks to CodewithHarry Channel for all the Quality Content for Free"+22*" "+"*\n*"+145*" "+"*\n"+147*"*") # Gratitude