For searching for over an year now, I was somehow able to find your videos. And actually these are the only videos out there on YT that are actually helpful for us! I am in class 11th, and will recommend this channel to every single CS student who are studying in 11th right now. Thnx for these videos...
i developed a very simple code for this ..for which only one for loop is enough n=int(input("no of rows required: ")) m=n-2 for i in range(1,n): print(' '*m,end='') print('x '*i) m=m-1
Bro how much ever i type it will be still confusing. Just put the same code and debug. i will try my best by typing. Inside ith loop{ 1st jth loop will stop by giving n-1 space in the same line. if num =4, we need 3 space in 1st line , then 2 space 2nd line , 1 space 3rd line , 0 space last line. so basically inside a loop 1st jth loop will give spaces till n-1. 2nd jth loop appends * and space. Once both gets over. We need to break out of that line . So used printf()
Bro i tried below query but i am getting below output num = int(input("Enter the number of rows:")) for i in range(0,num): for j in (0,num-i-1): print(end=" ") for j in range(0,i+1): print("*",end=" ") print() Output : * * * * * * * * * * * * * * *
That one person who uses the paint program to help us understand. I salute you for doing so. However, rumours say that the paint program will be removed! What program will you use next? Great video by the way! Helped me a lot in my work!
In this python programming for printing stars we can make use of "while loop" but you can't make use of "while loop " And my suggestion is both "while loop" and" for loop" also plzz update that also
this also works e = 6 for t in range(1,6): for y in range(1,e-t): print(end=' ') for y in range(1,t+1): print('*',end=' ') print() output * * * * * * * * * * * * * * *
Hi , I am print the pattern like below: A A B B C D D E F G But from my output why its coming like this .i mean why adding None Enter no of rows:4 A A B B C D D E F G None Program is: def requiredrows(num): #num=int(input("Enter the number of rows :")) ASCII=65 for i in range(0,num): for j in range(0,num-i-1): print (end=" ") for j in range(0,i+1): value=chr(ASCII) print ((value), end=" ") ASCII=ASCII+1 ASCII=ASCII-1 print (" ") num=int(input("Enter no of rows:")) print(requiredrows(num)) Could U please respond in mail padmarao.gpr@gmail.com
this is my program mam/sir num=int(input("enter the no.of rows")) for i in range(0,num): for j in range(0,num-i-1): print(end=" ") for j in range(0,i+1): print("*",end=" ") print()
Try this: num=int(input("enter the no.of rows")) for i in range(0,num): for j in range(0,num-i-1): print(end=" ") for j in range(0,i+1): print("*",end=" ") print() for loop placement is very important :)
@@AmulsAcademy hi madam My question is A= """what are you doing How are you I'm fine """ I want output : how many lines How many characters How many words in this string??
i think without using too much calculations we can simply execute it like this: using for loop: raw=int(input("enter the number of raw ")) s=raw-1 for num in range(1,raw): print(" "*s,"* "*num) s-=1 using while loop: raw=int(input("enter number of raw ")) num=1 s=raw-1 while num
for triangle best and single for loop function is def newStar(): inp=int(input("Please enter the number of rows")) for i in range(0,inp+1): print(' '*inp,end="") print('* '*i) inp-=1 try karo sabse easy
Hi Amulya, i have tried your query but i didn't get correct output which you have shown in video num = int(input("Enter the number of rows:")) for i in range(0,num): for j in (0,num-i-1): print(end=" ") for j in range(0,i+1): print("*",end=" ") print()
num = int(input("Enter the number of rows:")) for i in range(0,num): for j in range(0,num-i-1): print(end=" ") for j in range(0,i+1): print("*",end=" ") print() in the first for loop you missed range() for j in (0,num-i-1): :)
@@AmulsAcademy after num variable, I have mentioned for loop with range(0,num)...pls check in above code and also pls let me know the incremental scenario
This also Work num=int(input("Enter the number: ")) for x in range(1,num+1): for y in range(1,num-x+1): print(end=" ") for j in range(1,x+1): print("*",end=" ") print(" ")
For those who understand row/col context better than i/j :: # 'n' indicates number of rows & execute function as 'pattern(5)' def pattern(n): for row in range(n): for col in range(n-row-1): print(end=" ") for col in range(row+1): print("*", end=" ") print()
num = int(input('Enter the colums you want ')) for i in range(num): for j in range(num-i): print(end=' ') for k in range(num-j): print('*',end=' ') print()
If you are printing star pattern you can take range from 0 or you can take from 1 also. But in number pattern, we are printing row or column value that's why i took range from 0. You can take range from 0 or 1 that's doesn't matter in some cases like in star pattern programs. write program with both range [0 and 1] and see the difference . :)
mam the below code i used but i didnt got the perfect output n = input("enter the number of rows: ") for row in range(0,n+1): for space in range(0,n-row-1): print(" ") for col in range(1,row+1): print col, print (" ")
Try this: n = input("enter the number of rows: ") for row in range(1,n+1): for space in range(1,n-row+1): print " ", for col in range(1,row+1): print col, print :)
n=int(input("enter a number:")) for i in range(0,n): #pyramid-PATTERN print(" "*(n-i),"* "*i) Use this code to reduce execution time👍 if you understand this code YOU can write code for REVERSE-pyramid also very easyleeeeeee.
def pyra(rows): for i in range(rows): print(''*(rows-i-1)+'*'*(2*i+1)) ---gave me--------------------- >>> pyra(5) * *** ***** ******* ********* ------------------------------------- what did I do wrong?
just a thought. Instead of i and j it will be a good idea to use name as 'space' or 'stars' so as to be more specific. coz 'i' and 'j' makes no sense and makes it hard to understand
Mam jaise first row me 3rd position pr star print ho gya to uske bd direct row 1 me aa jayenge hum ya phir first row me jo star print hua hai uske bd bhi jo 3 space dikh rhe wo print krke next row me aayega .....
mam in the program you explained in this tutorial video...... in the for loop i.e, Eg for j in range (0,3) print ("*",end =" ") The output expected is... * (space) * (space) * (space) (Space)----> " " but the output is like.. * * * * Why this happens?? Is this because of end = " " at the end of print i.e, print ("*" , end =" ")
for j in range (0,3) print ("*",end =" ") Here for loop will execute like this: first j=0, so print("*",end=" ") will be executed. so it will print * and we can see end =" " so it will print space after star so we will get *(space)__ and control is still in the same line. j=0 ------------------------- *(space) Next again for loop will execute for j = 1, so it will again execute print("*",end=" ") so we will get j=0 j=1 --------------------------------------------------------------------------------- *(space) *(space)__ and control is still in the same line. Next again for loop will execute for j = 2, so it will again execute print("*",end=" ") so we will get j=0 j=1 j=2 --------------------------------------------------------------------------------- *(space) *(space) *(space)__ and control is still in the same line. Next for loop range is covered so it will come out of the loop, next in the program you can see print(), so now control will go to the next line. j=0 j=1 j=2 --------------------------------------------------------------------------------- *(space) *(space) *(space) ___ it will print next star in the next line. *Note : __ for showing where control is present.
@@AmulsAcademy Mam but i can't understand in this case... i.e , in the same program you explained in this tutorial video... a particular part alone i mentioned below for i in range (0 ,1): for j in range (0 , 3) : print (end = " ") for j in range (0,1): print (" * " , end = " ") print () then the output i expected is (space) (space) (space ) //1st j loop * ( space ) //2nd j loop But the output got is (space) (space) (space) * (space) Please explain this alone mam !!!
In India its Know as Rangoli competition code is:- n = int(input("Enter the number of rows")) print(" ".join([str("* "*i).center(n*2) for i in range(1,n+1)]))
Hello Ma'am please solve this problem Que:- Write unix `cat -n` equivalent command that will display the contents of the file along with line number of each line. # Complete the following display() method to display the file that is passed to the method. # # For example when passed a file with following content, # # line 1 # line 2 # line 3 # # It should produce following output. # # 1: line 1 # 2: line 2 # 3: line 3 # # To run the program, pass it an extra argument of file name that needs to be displayed for example if you want to display file program-1.py execute following command,
I don't no why in my program columns are increasing * ** ***** **** ** why it is getting like that no space before star am not getting in pyramid shape even though copy past result is same
num=int(input("Please enter the Number:")) for i in range(0,num): for j in range(0,num-i-1): print(end="") for j in range(0,i+1): print("*",end="") print() But Start * is not show center * ** *** **** ***** like this
Excuse me your videos are good but I have a doubt in this question what if we write print(" ",end=" ") instead of (end=" ") in line number 4 I.e is in first j loop
hey, print(end=" ") this line is to print space , so, you can write like this, print(" ",end="") that is space and end is equal to empty string. We use end="" because we want to keep the control in the same line if you write print(" ",end=" ') that is print space and end is equal to space it will take double space and in the program we want single space so you can write print(end=" ") or you can write print(" ",end="") Thank you:)
x=int(input("enter no.")) for i in range(0,x): for j in range(0,x-i-1): print(end=" "): for j in range(0,i+1): print("*",end=" ") print() Idk why this code is not running showing error
Try this- n=int(input("enter the number of rows:") for i in range(0,n): for j in range(0,n-i-1): print(end=" ") for j in range(0,i+1): print("*",end=" ") print(end=" ") print()