1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aleksklad [387]
2 years ago
12

Q1). Write a python program to pass a list to a function and double the odd values and half even values of a list and display li

st elements after changing.​
Computers and Technology
1 answer:
zepelin [54]2 years ago
8 0

Answer:

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Python.

def f(x):

   new_list=[]

   for i in x:

       if i%2==0:

           new_list.append(i//2)

       else:

           new_list.append(i*2)

   return new_list

   

my_list=list(range(1,6))

print('Original List:',my_list)

my_list=f(my_list)

print('Modified List:',my_list)

\textsf{\large{\underline{Logic}:}}

  1. Create a new list.
  2. Iterate over the list passed into the function.
  3. Check if the element is even or not. If true, append half the value of element in the list.
  4. If false, append twice the value of the element in the list.
  5. At last, return the new list.

There is another way of doing this - By using map() function.

—————————————————————————————

def f(x):

   return list(map(lambda x:x//2 if x%2==0 else 2*x,x))

   

my_list=list(range(1,6))

print('Original List:',my_list)

my_list=f(2my_list)

print('Modified List:',my_list)

—————————————————————————————

\textsf{\large{\underline{O{u}tput}:}}

Original List: [1, 2, 3, 4, 5]

Modified List: [2, 1, 6, 2, 10]

You might be interested in
Fill in the blank: Every database has its own formatting, which can cause the data to seem inconsistent. Data analysts use the _
dmitriy555 [2]

The tool used by data analysts to create a clean and consistent visual appearance for their spreadsheets is called <u>clear formats</u>.

A database refers to an organized or structured collection of data that is typically stored on a computer system and it can be accessed in various ways. Also, each database has a unique formatting and this may result in data inconsistency.

In Computer science, a clean data is essential in obtaining the following:

  • Data consistency
  • Data integrity
  • Reliable solutions and decisions.

Furthermore, spreadsheets are designed and developed with all kinds of tools that can be used to produce a clean data that are consistent and reliable for analysis.

In this context, clear formats is a kind of tool that is used by data analysts to create a clean and consistent visual appearance for their spreadsheets.

Read more on database here: brainly.com/question/15334693

8 0
2 years ago
Write a program that represents a popular kid’s toy that teaches them about different shapes and colors.
SVEN [57.7K]

Answer:

blue circle

Explanation:

7 0
3 years ago
What is the name of the function below?<br><br> function go(){<br> alert("hello everybody");<br> }
labwork [276]

Answer:

It’s Java script I think and it makes something say hello everybody

Explanation:

6 0
3 years ago
After inserting a video into your slide how can you test it
blagie [28]

Explanation:

How to insert video into PowerPoint

  1. Click on the slide you want, then go to Menu > Insert.
  2. In the top right corner, click Video > Video on My PC.
  3. Find the video you want to add and click “Insert”.
  4. Adjust the settings in the Video Format toolbar to make sure it plays the way you want.
7 0
3 years ago
Which two editions of Windows 7 support 64 bit CPUs? Choose two out of Professional, Business, Starter, or Home Premium.
Tju [1.3M]
Home premium, professional
6 0
3 years ago
Other questions:
  • Being tired has very similar effects on the body as what
    7·1 answer
  • Davia draws a shape with 5 sides. two sides are each 5 inches long. two other sides are each 4 inches long. the perimeter of the
    15·1 answer
  • THE bestValue PROBLEM Using the Camera structure defined in file p1.cpp, write the function named bestValue(). The function take
    13·1 answer
  • 1. In your own words, describe the purpose of a for a loop.
    11·1 answer
  • One advantage of using personal computers for Internet access is that they have relatively large screens for viewing Internet co
    7·2 answers
  • Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any ot
    10·1 answer
  • Which of the following tasks can you perform using a word processor?
    8·1 answer
  • Add the following method to the Point class: public double distance(Point other) Returns the distance between the current Point
    12·1 answer
  • An example of computer hardware is ? A. keyboard B. app C. web browser D. operating system
    13·2 answers
  • What is the most common knowledge computer programmers need in order
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!