Computer Science, asked by asthaankita6943, 12 hours ago

Write a program in Python to create the following list and convert the even elements to its half and odd elements to double.

Answers

Answered by GodofTeaching
7

Answer:

Explanation:

lst = [2,7,55,68,23,89,6,10,135,99,44,12]

new_list=[]

for i in lst:

   if i%2==0:  # if number is even

       item=int(i/2)   # make it half

       new_list.append(item)   # append to new list

   else:   # if number is odd

       item=int(i*2)   # make it double

       new_list.append(item)   # append to new list

print(new_list)

Answered by Rameshjangid
0

Answer:- We need to write a program in python to create the list and convert the even elements to its half and the odd elements to double. The program is written:-

new_list=[]

for i in lst:

  if i%2==0:  # if number is even

      item=int(i/2)   # make it half

      new_list.append(item)   # append to new list

  else:

 # if number is odd

      item=int(i*2)   # make it double

      new_list.append(item)   # append to new list

print(new_list)

Python is currently the most widely used multi-purpose and high-level programming language now a days.

The Python programming allows programming in Object Oriented and Procedural paradigms.

All Python programs generally are smaller than other programming languages like Java, etc.

The Python language is being used by almost all technical giant companies like – Google, Amazon, Facebook, Instagram, etc.

To know more about the given topic please go through the following

Link1:- https://brainly.in/question/47181627?

Link2:- https://brainly.in/question/31513087?

#SPJ3

Similar questions