In this program, we will take a user input as a list and print squares of even numbers from that list with the help of the below-given steps.
Squares of even numbers:
Steps to solve the program
- Take a list as input.
- Using for loop check whether an element from the list is even or not.
- If an element is even then print its square using **n.
#Input list
list1 = [2,4,7,8,5,1,6]
for value in list1:
if value%2 == 0:
#Printing output
print(value,":",value**2)
Output :
2 : 4
4 : 16
8 : 64
6 : 36