Class 11 Exam  >  Class 11 Questions  >  Write a python program to input a list of int... Start Learning for Free
Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​?
Most Upvoted Answer
Write a python program to input a list of integer numbers from user an...
**Python program to find square of even numbers and cube of odd numbers in a list**

In this program, we will take a list of integers from the user and find the square of even numbers and the cube of odd numbers.

**Step-by-step approach:**

1. First, we will take input from the user for the list of integers.
2. Then, we will create an empty list to store the result of the square of even numbers and the cube of odd numbers.
3. Next, we will iterate through each element of the list.
4. If the number is even, we will find its square and append it to the result list.
5. If the number is odd, we will find its cube and append it to the result list.
6. Finally, we will print the result list.

**Python code:**

```python
# take input from user for list of integers
lst = list(map(int, input("Enter a list of integers: ").split()))

# create an empty list to store result
result = []

# iterate through each element of the list
for num in lst:
# if number is even, find its square and append to result list
if num % 2 == 0:
result.append(num ** 2)
# if number is odd, find its cube and append to result list
else:
result.append(num ** 3)

# print the result list
print("Result:", result)
```

**Output:**

```
Enter a list of integers: 1 2 3 4 5
Result: [1, 4, 27, 16, 125]
```

In the above example, we have taken a list of integers from the user as input and found the square of even numbers and the cube of odd numbers. The result is stored in the `result` list and printed at the end.
Community Answer
Write a python program to input a list of integer numbers from user an...
# Python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers
#Entering a list from user
list1=eval(input("Enter a list of numbers:"))
#Creating an empty list for even and odd numbers
even=[ ]
odd=[ ]
for i in list1:
if i%2==0:
even.append(i)
else:
odd.append(i)
#Creating an empty list for sq of even and cube of odd
even_square=[ ]
odd_cube=[ ]
for j in even:
square=j**2
even_square.append(square)
for n in odd:
cube=n**3
odd_cube.append(cube)
#Displaying even no.& their squares and odd no.s and their cube
print("even numbers are:",even,"and their squares are",even_square)
print("odd numbers are:",odd,"and their cubes are:",odd_cube)
Attention Class 11 Students!
To make sure you are not studying endlessly, EduRev has designed Class 11 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 11.
Explore Courses for Class 11 exam

Top Courses for Class 11

Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​?
Question Description
Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? for Class 11 2024 is part of Class 11 preparation. The Question and answers have been prepared according to the Class 11 exam syllabus. Information about Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? covers all topics & solutions for Class 11 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​?.
Solutions for Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? in English & in Hindi are available as part of our courses for Class 11. Download more important topics, notes, lectures and mock test series for Class 11 Exam by signing up for free.
Here you can find the meaning of Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? defined & explained in the simplest way possible. Besides giving the explanation of Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​?, a detailed solution for Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? has been provided alongside types of Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? theory, EduRev gives you an ample number of questions to practice Write a python program to input a list of integer numbers from user and finding square of even numbers and cube of odd numbers ​? tests, examples and also practice Class 11 tests.
Explore Courses for Class 11 exam

Top Courses for Class 11

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev