In today’s exercise, what we have to do is, we have to print a pattern similar to that of a right-angle triangle, such as:
*
**
***
****
If you are following my playlist and watching the Python tutorials in series, then it is a must for you to solve this problem and share your answer by commenting.
This will enhance and increase your skills, along with boosting my morale.
Your participation will be very much appreciated. Keep supporting and stay up to date with codewithharry.
# Exercise 4
# Pattern Printing
# Input = Integer n
# Boolean = True or False
#
# True n=5
# *
# **
# ***
# ****
#
# False n=5
# ****
# ***
# **
# *
I am trying to paste the code here , but it is getting messed up!!
same here bro 500 is word limit
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
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
print("printing starts") n=int(input("enter the length of the string")) val=int(input("enter a bool value \n 1 for true and 0 for false")) if bool(val): i=0 while i<n : j=0 while j<i+1: print("*",end="") j=j+1 print("\n",end="") i=i+1 else : i=n while i>0: j=i while j>0: print("*",end="") j=j-1 print("\n",end="") i=i-1
#Author : lone_wolf #last part (coz problem in uploading on site due to word limit or else) i-=1 n=input("enter no of row you want in astrologer star>>>") k=int(input("enter a value '1' for ascending order and '0' for decending order>>")) def check(k): return(bool(k==1)) if(check(k)): ascending_str(n) print("program end here!!!") else: decending_str(n) print("program end here!!!")
num = int(input("Enter the Number to print the Number of Stars : ")) A = bool(int(input("Enter 0 or 1 (0 {For Up side down Triangle}) \n " "(1 {for Right Angle Triangle }) : "))) if A == True: for i in range(1, num + 1): print("* " * i) else: for i in range(num): i = num - i print("* " * i)
#printing star pattern i=1 print("Please enter a number") get = int(input()) print("Enter a number\nfor True :1 \nfor False :0") Bool = int(input()) if Bool==1: while i<=get: print("*"*i) i = i + 1 continue elif Bool==0: while i<=get: print("*"*get) get=get - 1 continue else: print("sorry given wrong input")
No downloadable resources for this video. If you think you need anything, please post it in the QnA!
Any Course related announcements will be posted here