CBSE Class 12 Computer Science
Question 88 of 120
Review of Python Basics — Question 40
Back to all questions 40
Question Write a Python program to generate and print a list of first and last 5 elements where the values are square of numbers between 1 and 30 (both included).
squares = []
for num in range(1, 31):
squares.append(num ** 2)
first_5 = squares[:5]
last_5 = squares[-5:]
combined_list = first_5 + last_5
print("Combined list:", combined_list)Combined list: [1, 4, 9, 16, 25, 676, 729, 784, 841, 900]