Class 11 Practical Programs-Term II
Class 11 Practical Programs-Term II
11.Write a menu driven program to generate the following patterns using nested loops:-
while True:
print("\nMenu:")
print("1. Print Pattern-1")
print("2. Print Pattern-2")
print("3. Exit")
choice = int(input("Enter your choice (1/2/3): "))
if choice == 1:
print("\nPattern-1:")
rows = 5
for i in range(rows, 0, -1):
for j in range(1, i + 1):
print(j, end="")
print()
elif choice == 2:
print("\nPattern-2:")
rows = 5
for i in range(1, rows + 1):
for j in range(65, 65 + i): # ASCII value of 'A' is 65
print(chr(j), end="")
print()
elif choice == 3:
print("Exiting the program.")
break
else:
print("Invalid choice! Please try again.")
12. Write a program to input the value of x and n and print the sum of the following series: