Q:

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).

0

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).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def printValues():
	l = list()
	for i in range(1,21):
		l.append(i**2)
	print(l[:5])
	print(l[-5:])

printValues()

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now