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
inessss [21]
3 years ago
12

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.student.py HNM 1 - Hef filter_only_certain_strings (data_list): new_list = [] for data in data_list: if type (data) == str and len(data) >= 5: new_list.append(data) return new_list Restore original file Save & Grade Save only
Computers and Technology
1 answer:
Nataliya [291]3 years ago
6 0

Answer:

Explanation:

The Python code that is provided in the question is correct just badly formatted. The snippet of code that states

return new_list

is badly indented and is being accidentally called inside the if statement. This is causing the function to end right after the first element on the list regardless of what type of data it is. In order for the code to work this line needs have the indentation removed so that it lines up with the for loop. like so... and you can see the correct output in the attached picture below.

def filter_only_certain_strings(data_list):

   new_list = []

   for data in data_list:

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

           new_list.append(data)

   return new_list

You might be interested in
Citing the recent increase in earnings by several computer companies, economists feel that a cycle has begun in which personal c
VashaNatasha [74]

Answer:

A) a cycle has begun in which personal computer users

Explanation:

Option A as already used in the question fits and and completes the question correctly, this is because the because the writter is trying to communicate a new 'era', 'dispensention', 'period' or 'season'.... this is appropriately communicated with the word 'cycle'.

5 0
3 years ago
Suppose you have an int variable called number. What Java expression produces the second-to-last digit of the number (the 10s pl
kobusy [5.1K]

Answer:

int second_to_last = (number/10)%10;

int third_to_last = (number/100)%10;

Explanation:

The first expression int second_to_last = (number/10)%10; first divide the number by ten and then get modulus by dividing by ten again which will then give the second to last digit.

Assuming number is 146 the second to last digit will be 4.

for the second expression int third_to_last = (number/100)%10; first divide the number by hundred and then get modulus by dividing by ten which will then give the third to last digit.

Assuming number is 4368 the third to last digit will be 3.

4 0
3 years ago
After selecting the Slide Master tab (within the View tab), which actions can a user take to configure a slide master?
myrzilka [38]

Answer:

Yes those are the correct order.

Explanation:

5 0
3 years ago
Computer simulations were first developed during __________<br> as a part of the _____________
Effectus [21]

Answer:

WWII; Manhattan Project.

Explanation:

Computer simulation refers to a mathematical model designed and developed to predict the outcome or behavior of a hypothetical or real-life scenario on a computer system, so as to illustrate and understand how the system functions.

Historically, computer simulations were first developed during World War II (WWII) as a part of the Manhattan Project.

For example, SimpleScalar refers to a computer architectural simulating software application or program which was designed and developed by Todd Austin at the University of Wisconsin, Madison, United States of America. It is an open source simulator written with "C" programming language and it's used typically for modelling virtual computer systems having a central processing unit (CPU), memory system parameters (hierarchy), and cache.

6 0
3 years ago
Weak Induction
slega [8]

Answer:

Following are the answer to this question:

Explanation:

In option 1:

The value of n is= 7, which is (base case)

\to 3^7

when n=k for the true condition:

\to 3^k

when n=k+1 it tests the value:

\to 3^{(k+1)}= 3^k,3\\\to < (k!) 3 \ substituting \ equation \\\to

since k>6  hence the value is KH>3 hence proved.

In option 2:

when:

for n=1:(base case)

\log(1!)

0<=0 \\ condition is true

when the above statement holds value n=1

when n=k

\log(k!)

when n=k+1

\log(k+1)!=\log(k!)+\log(k+1)\\

             

\because k \log k      [\therefore KH>K \Rightarrow  \log(KH>\loK)]

In option 3:

when n=1:

A_1 \cup B=A_1 \cup B\\\\

when n=k

\to (A_1\cap A_2 \cap.....A_k) \cup B\\=(A_1\cup B) \cap(A_2\cup B_2)....(A_k \capB).....(a)\\\to n= k+1\\ \to (A_1\cap A_2 \cap.....A_{kH}) \cup B= (A_1\cup B)\\\\\to  [(A_1\cap A_2 \cap.....A_{k}) \cup B]\cap (A_{KH}\cup B)\\\\\to  [(A_1\cup B) \cap (A_2 \cup B) \cap (A_3\cup B).....(A_k\cup B)\cap (A_{k+1} \cup B)\\\\  \ \ \ \ \ \ substituting \ equation \ a \\\\

hence n=k+1 is true.

7 0
3 years ago
Other questions:
  • Tom wants a way to automatically create ads and simplify campaign management, using his resources and Google's machine learning
    12·1 answer
  • Define and test a function myRange. This function should behave like Python’s standard range function, with the required and opt
    13·2 answers
  • Why is it important to evaluate the website on which you plan to shop?
    7·2 answers
  • Can i edit my name on this app?
    7·1 answer
  • MULTIPLE CHOICE:
    15·1 answer
  • Does white space have visual weight? Yes or No
    7·2 answers
  • Importance of computer​
    15·1 answer
  • You wrote a program to allow to guess a number chosen randomly.
    10·2 answers
  • Write the two features of a mouse.​
    9·1 answer
  • Sharl downloads images from an online library and uses them in her work. The images are shared under the Creative Commons Attrib
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!