9. Problem to print squares of even numbers from a list.

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
  1. Take a list as input.
  2. Using for loop check whether an element from the list is even or not.
  3. 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
				
			

Related Articles

Combination of 2 elements from the list whose sum is 10.

split the list with even,odd values

Leave a Comment