Answers for "Write a Python program to generate a list of squares of numbers between 1 and 20 (both nos included) and print ONLY the first and last 5 elements"

0

Write a Python program to generate a list of squares of numbers between 1 and 20 (both nos included) and print ONLY the first and last 5 elements

num_list = list(range(1,21))

sq_list = [r for r in map(lambda x: x**2 , num_list)]

print("the first five elements are \n{}\n the last five elements are\n{}".format(sq_list[:5] , sq_list[-5:]))
Posted by: Guest on September-09-2021

Code answers related to "Write a Python program to generate a list of squares of numbers between 1 and 20 (both nos included) and print ONLY the first and last 5 elements"

Python Answers by Framework

Browse Popular Code Answers by Language