Posts

Showing posts from February, 2020

CODE to print rhombus in python

Image
How to print rhombus in python ? code: n=int(input("enter size of rhombus")) i=1 k=n while(i<=n):        #this loop will print n numbers of rows     while(k>=1):    #this loop is used to gave spaces         print(" "*k,end="") #this line will print k number of spaces         print("*"*n)      #this line will print n number of asterix symbol         k=k-1     i=i+1 output: THANKYOU    

print pattern 12345 , 23451, 34512 ,45123 ,51234 in c++ and python

Image
12345 23451 34512 45123 51234 How to print this pattern in c++? CODE: #include<iostream> #include<conio.h> using namespace std; int main() { int i=1,k,j;   while(i<=5)   { j=i;     while(j<=5)     {         cout<<j;         j++;     }     k=1;     while(k<i)     {         cout<<k;         k++;     }     cout<<endl;     i++;   } } OUTPUT: How to print this pattern in python? CODE: i=1 while(i<=5):     j=i     while(j<=5):         print(j,sep="",end="")         j=j+1     k=1     while(k<i):         print(k,sep="",end="")         k=k+1     print()     i+=1 O...

CODE to Print a square(hollow) in python

Image
Print a square(hollow) in python n=int(input("enter any number")) i=1 while(i<=n):     if(i==1 or i==n):         print("*"*n)             else:          print("*",end="")          print(" "*(n-2),end="")          print("*")             i+=1 OUTPUT : THANKYOU