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
posledela
3 years ago
10

The function below takes a single argument: data_list, a list containing a mix of strings and numbers. The function tries to use

the Filter pattern to filter the list in order to return a new list which contains only strings longer than five characters. The current implementation breaks when it encounters integers in the list. Fix it to return a properly filtered new list.
Engineering
1 answer:
pychu [463]3 years ago
3 0

Answer:

def filter_only_certain_strings(data_list):

   new_list = []

   for data in data_list:

       # fix here. change >= to >  

       # because we want to return strings longer than 5 characters in length.

       if type(data) == str and len(data) > 5:

           new_list.append(data)

   return new_list

Explanation:

def filter_only_certain_strings(data_list):

   new_list = []

   for data in data_list:

       # fix here. change >= to >  

       # because we want to return strings longer than 5 characters in length.

       if type(data) == str and len(data) > 5:

           new_list.append(data)

   return new_list

You might be interested in
In this assignment, you will demonstrate your ability to write simple shell scripts. This is a cumulative assignment that will c
nevsk [136]

Answer:

Explanation:

Usage: flip [-t|-u|-d|-m] filename[s]

  Converts ASCII files between Unix, MS-DOS/Windows, or Macintosh newline formats

  Options:

     -u  =  convert file(s) to Unix newline format (newline)

     -d  =  convert file(s) to MS-DOS/Windows newline format (linefeed + newline)

     -m  =  convert file(s) to Macintosh newline format (linefeed)

     -t  =  display current file type, no file modifications

8 0
3 years ago
For a body moving with simple harmonic motion state the equations to represent: i) Velocity ii) Acceleration iii) Periodic Time
max2010maxim [7]

Answer with Explanation:

The general equation of simple harmonic motion is

x(t)=Asin(\omega t+\phi)

where,

A is the amplitude of motion

\omega is the angular frequency of the motion

\phi is known as initial phase

part 1)

Now by definition of velocity we have

v=\frac{dx}{dt}\\\\\therefore v(t)=\frac{d}{dt}(Asin(\omega t+\phi )\\\\v(t)=A\omega cos(\omega t+\phi )

part 2)

Now by definition of acceleration we have

a=\frac{dv}{dt}\\\\\therefore a(t)=\frac{d}{dt}(A\omega cos(\omega t+\phi )\\\\a(t)=-A\omega ^{2}sin(\omega t+\phi )

part 3)

The angular frequency is related to Time period 'T' asT =\frac{2\pi }{\omega }

where

\omega is the angular frequency of the motion of the particle.

Part 4) The acceleration and velocities are plotted below

since the maximum value that the sin(x) and cos(x) can achieve in their respective domains equals 1 thus the maximum value of acceleration and velocity is A\omega ^{2} and A\omega respectively.

4 0
3 years ago
Consider two different versions of algorithm for finding gcd of two numbers (as given below), Estimate how many times faster it
juin [17]

Answer:

Explanation:

Step 1:

a) The formula for compute greatest advisor is

     gcd(m,n) = gcd (n,m mod n)

the gcd(31415,14142) by applying Euclid's algorithm is

    gcd(31,415,14,142) =gcd(14,142,3,131)

                                  =gcd=(3,131, 1,618)

                                   =gcd(1,618, 1,513)

                                   =gcd(1,513, 105)

                                   =gcd(105, 43)

                                    =gcd(43, 19)

                                     =gcd(19, 5)

                                      =gcd(5, 4)

                                      =gcd(4, 1)

                                      =gcd(1, 0)

                                      =1

STEP 2

b)  The number of comparison of given input with the algorithm based on  checking consecutive integers and Euclid's algorithm is

     The number of division using Euclid's algorithm =10 from part (a)

      The consecutive integer checking algorithm:

      The number of iterations =14,142 and 1 or 2 division of iteration.

        14,142 ∠= number of division∠ = 2*14,142

         Euclid's algorithm is faster by at least 14,142/10 =1400 times

          At most 2*14,142/10 =2800 times.

5 0
3 years ago
Assume the impedance of a circuit element is Z = (3 + j4) Ω. Determine the circuit element’s conductance and susceptance.
djyliett [7]

Answer:

B. G = 333 mS, B = j250 mS

Explanation:

impedance of a circuit element is Z = (3 + j4) Ω

The general equation for impedance

Z = (R + jX) Ω

where

R = resistance in ohm

X = reactance

R = 3Ω  X = 4Ω

Conductance = 1/R while Susceptance = 1/X

Conductance = 1/3 = 0.333S

= 333 mS

Susceptance = 1/4 = 0.25S

= 250mS

The right option is B. G = 333 mS, B = j250 mS

8 0
2 years ago
Create two arrays with 5 elements each: one will hold Strings and the second will hold integers. Write a program to ask the user
MrMuchimi

Answer:

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main() {

   string name[5];  

   int age[5];  

   int i,j;  

   for ( i = 0; i<=4; i++ ) {  

       cout << "Please enter student's name:";  

       cin >> name[i];  

       cout << "Please enter student's age:";  

       cin >> age[i];          

   }  

for (i=0;i<=4;i++){

   cout<<"Age of  "<< name[i]<<"  is  "<<age[i]<<endl;  

}

}

Output of above program is displayed in figure attached.

5 0
3 years ago
Other questions:
  • A 600-MW steam power plant, which is cooled by a nearby river, has a thermal efficiency of 54 percent. Determine the rate of hea
    9·1 answer
  • A manufacturer makes integrated circuits that each have a resistance layer with a target thickness of 200 units. A circuit won't
    5·1 answer
  • You can divide a surface by drawing a line through it
    9·2 answers
  • Calculate the number of atoms per cubic meter in Metal B (units atoms/m^3). Write your answer with 4 significant figures metal:
    11·1 answer
  • Determine the average and rms values for the function, y(t)=25+10sino it over the time periods (a) 0 to 0.1 sec and (b) 0 to 1/3
    9·1 answer
  • 1. A turbine in a steam power plant operates isentropically with an inlet pressure (P3) of 3.5 MPa and inlet temperature (T3) of
    9·1 answer
  • I have a question for you guys
    13·2 answers
  • 11. Technicians A and B are discussing
    12·1 answer
  • Omplete the following program: [0.5 X 4 = 2]
    11·1 answer
  • A protocol is a set of rules or procedures, usually written, that should be followed in specific situations. Which of the follow
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!