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).
Answer =
lst = [ ] for i in range(1,6): lst += [ i**2 ] for i in range(6,26): lst += [ i ] for i in range(26,31): lst += [ i**2 ] print(lst)
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )