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
Marrrta [24]
3 years ago
9

How to create a function, called separate_int_and_str, which takes in a list and separates out the integer values and strings in

to their own lists in python?
Computers and Technology
1 answer:
gregori [183]3 years ago
4 0

Answer:

program :

def separate_int_and_str(list_1):# function to seprate the list.

   str_list=[] #list to hold the

   int_list=[]#list which holds the integer value.

   for x in list_1: #for loop to extract the list.

       if(type(x)==str): #if condition to check the type of the element.

           str_list.append(x)#create a list for the string value.

       elif(type(x)==int): #check condition for th einteger value.

           int_list.append(x)#create a list for the integer value.

Explanation:

  • The above-defined function is written in the python language, which used the code to separate the list for integer and the string value.
  • There are two lists define in the function which holds the integer and the string value separately.
  • There is a 'for' loop which scans the element of the list and checks the list by the help of type function which tells the class of the element.
  • Then if the type function states that the element is from the strong class, it will assign the element on the string list otherwise it assigns the element in the integer list.
You might be interested in
When a number gets assigned to a variable that already has a value __________?
Aleksandr-060686 [28]
A already assigned variable cannot be assigned twice You can make the variable change over to a new one or call a whole new one to assign one without a value or It might be possible to do v=n (v is variable and n is number / value)
3 0
3 years ago
For each problem listed below, use the drop-down menu to select the field of the professional who can help solve the issue.
Paul [167]

Answer:

  • Interactive media
  • Information services and support
  • Programming and software development
  • Network systems administration

Explanation:

The company has finished designing a software program, but users aren’t sure how to use it. <u>interactive media</u>

Several people in the human resources department need new software installed. <u>information services and support</u>

An employee has an idea for a software program that can save the company time, but doesn’t know how to write it. <u> programming and software development</u>

A new branch of the company is opening soon, and the computers there need to be connected to the Internet. <u>network systems administration</u>

<u>OAmalOHopeO</u>

3 0
3 years ago
Karel coding 2.1.4 superkarel cleanup
kherson [118]

Answer:

hi, try using Code Plans

Explanation:

it is a free website that include videos and articles on this stuff

6 0
2 years ago
Read 2 more answers
A method to accept the number of drawers in the desk as input from the key board. This method returns the number of drawers to t
Julli [10]

Answer:

Following code takes the information about the wood from the user, do the process of calculating the value according to there type and numbers, then add the surcharge to it while giving the answer to the user.

For differentiating the type of woof i used the if then else statement while i used switch case statement for assigning the appropriate value according to the types of the wood will be processing in the program.

The code is given below:

Explanation:

Code:

namespace std;\\ any name instead of std.

{

   class Program

   { \\ starting the main program

       static void Main(string[ ] args)

       {

           int numberOfDrawers = 0;

           string deskWoodType = "o";

           double cost = 0;

           drawersMeth(numberOfDrawers);

           woodTypeMeth(deskWoodType);

           CalculateCostMeth(numberOfDrawers, cost, deskWoodType);

           OutPutCostMeth(deskWoodType , cost, numberOfDrawers);

       }//end main

       private static void drawersMeth(int numberOfDrawers)

       {

           int numOfDrawers;

           Console.WriteLine("Enter the number of desk drawers");

           numOfDrawers = Convert.ToInt16(Console.ReadLine());

           numberOfDrawers = numOfDrawers;

       }//end drawersMeth

       private static string woodTypeMeth(string deskWoodType)

       {

           Console.WriteLine("Enter the desk wood type. (eg. type mahogany, oak, or pine)");

           deskWoodType = Convert.ToString(Console.ReadLine());

           switch (deskWoodType)

           {

               case "mahogany":

                   {

                       deskWoodType = "m";

                       break;

                   }

               case "oak":

                   {

                       deskWoodType = "o";

                       break;

                   }

               case "pine":

                   {

                       deskWoodType = "p";

                       break;

                   }

               default:

                   {

                       deskWoodType = "error";

                       break;

                   }

           }

           return deskWoodType;

       }// end woodTypeMeth

       private static int CalculateCostMeth(string deskWoodType, int numberOfDrawers, int cost)

       {

           int pine = 100;

           int oak = 140;

           int other = 180;

           int surchage = 30;

           if (deskWoodType == "p")

               cost = surchage + (numberOfDrawers *pine );

           else if (deskWoodType == "o")

               cost = surchage + (numberOfDrawers *oak );

           else

               cost = surchage + (numberOfDrawers *other );

           return cost;

       }// end CalculateCostMeth

       private static void OutPutCostMeth(int numberOfDrawers, string deskWoodType, int cost)

       {

           double totalCost = cost;

           Console.WriteLine("The number of drawers is {0}", numberOfDrawers);

           Console.WriteLine("The wood finish you have selected is ", deskWoodType);

           Console.WriteLine("The total cost is {0}", totalCost);

       }//end outputCost

   }//end class

}//end nameSpace

5 0
3 years ago
Which avenue may utilize video streaming, audio narration, print designs, and animation?
astra-53 [7]

Answer: is their any options to answer your question

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • A company has a network printer that is utilzed by several departments. Although the printer shows online and other departments
    11·1 answer
  • I am confused about joins in sql.
    8·2 answers
  • What kind of device is a printer? output or input
    13·1 answer
  • • Write a program to find the maximum, minimum, and average score of players. The input to the program is a file containing play
    9·1 answer
  • In bankruptcy, most of a debtor’s assets will probably be used to repay unsecured debt
    9·1 answer
  • You want to purchase a new hard drive for your workstation and are deciding between an HDD and an SDD. Which of the following is
    13·1 answer
  • What happens when two computers use the same IP address?
    15·1 answer
  • hich type of denial of service (DoS) attack occurs when a name server receives malicious or misleading data that incorrectly map
    6·1 answer
  • What is the cpu used for
    6·1 answer
  • Do you think that the TV set has outlived its utility as a household appliance? Research how convergence with internet technolog
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!