About Lesson
Display following patterns using Python
Pattern
Python Code
number = int(input("Enter Number: ")) x = 0 for i in range(1, number + 1): x = x + i for j in range(1, i + 1): if i%2 == 1: c = x - j + 1 else: c = x + j - i print(c, end=" ") print("")
number = int(input("Enter Number: ")) x = 0 for i in range(1, number + 1): x = x + i for j in range(1, i + 1): if i%2 == 1: c = x + j - i else: c = x - j + 1 print(c, end=" ") print("")
number = int(input("Enter Number: ")) x = 0 for i in range(0, number + 1): print(" "*(number - i), end="") for j in range(-i, i + 1): print(number - abs(j) + 1 if j != 0 else 0, end="") print("")
number = int(input("Enter Number: ")) for i in range(1, number + 1): for j in range(1, i + 1): print(chr(j+64) + chr(j+96), end="") print("")
number = int(input("Enter Number: ")) for i in range(1, number+1): print(" "*(number-i), end="") for j in range(-i+1, i): print(chr(abs(j)+65), end="") print("")
number = int(input("Enter Number: ")) for i in range(1, number+1): print(" "*(number-i), end="") for j in range(-i+1, i): print(chr(i-abs(j)+64), end="") print("")
number = int(input("Enter Number: "))
for i in range(1, number+1):
for j in range(i, 0, -1):
print(chr(i+(32*(3-j%2))), end=" ")
print("")
number = int(input("Enter Number: ")) for i in range(1, number+1): for j in range(1, i+1): print(j+number-i, end="") print(str(number)*(number-i))
number = int(input("Enter Number: ")) for i in range(1, number+1): if i%2: print(chr(i+64), end=" ") else: print(chr(i+96), end=" ")
number = int(input("Enter Number: "))
for i in range(1, number+1):
for j in range(1, number+1):
if i==j:
print(i, end=" ")
else:
print("0 ", end="")
print("")