SOME IMPORTANT PATTERN IN PYTHON 2.7.15 PROGRAMMING LANGUAGE
n=input("enter any number")
for i in range(n):
for i in range(n):
print("*")*i
print("*")*(i+1)
for i in range(n,0,-1):
print("*")*i
Question 2..
n=int(input("enter the number"))
print("\n")
for i in range(0,n):
print(" ")*i,
for j in range(n,i,-1):
print("*"),
print
enter the number6
* * * * * *
* * * * *
* * * *
* * *
* *
Question 3.
for i in range(4,-1,-1):
print(" ")*i,
for j in
range(5,i,-1):
print("*"),
for k in
range(4,i,-1):
print("*"),
print
OUTPUT::::
*
* * *
* * * *
*
* * * * * * *
* * * * * * * * *
QUESTION 4.
for i in range(4,-1,-1):
print(" ")*i,
for j in
range(5,i,-1):
print("*"),
for k in
range(4,i,-1):
print("*"),
print
for i in range(1,5):
print(" ")*i,
for j in
range(4,i-1,-1):
print("*"),
for k in
range(4,i,-1):
print("*"),
print
OUTPUT:::
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
Question 5.
k=1
for i in range(1,8):
if (i%2!=0):
print("+-+-+-+-+-+")
else:
for j in range(1,4):
print
"|",k,
k=k+1
print(“|”)
print
OUTPUR::..
+-+-+-+
| 1 | 2 | 3|
+-+-+-+
| 4 | 5 | 6|
+-+-+-+
| 7 | 8 | 9|