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

Answers

Answer 1

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

The Function Below Takes A Single Argument: Data_list, A List Containing A Mix Of Strings And Numbers.

Related Questions

what is convergence ​

Answers

Answer:

the process or state of converging.

Explanation:

Answer:

the fact that two or more things, ideas, etc. become similar or come together.

Write a function charInWord that takes in two parameters, a char (character) and a word (string). The program will return true if the character is in the word and false if it is not. If word is not a string type, or if char is not a string type, or if the length of char is greater than 1, the function should return None. Your main program should call the function and print char is in word if the function returns true, or char is not in word if the function returns false, using the user-supplied values instead of char and word. The program should print incorrect input provided if the function returns None. Ex: If the input is: a cat the output is: a is in cat Ex: If the input is: a club the output is: a is not in club Ex: If the input is: ab horse the output is:

Answers

Answer:

The program in Python, is as follows:

def charInWord(chr,word):

   if len(chr)>1:

       print("None")

   elif not(chr.isalpha() and word.isalpha()):

       print("None")

   else:

       if word.find(chr) == -1:

           print(chr+" is not in "+word)

       else:

           print(chr+" is in "+word)

chr = input("Character: ")

word = input("Word: ")

print(charInWord(chr,word))

Explanation:

This defines the function

def charInWord(chr,word):

This checks if the length of character is greater than 1

   if len(chr)>1:

If yes, it prints None

       print("None")

This checks if the character or the word contains invalid character

   elif not(chr.isalpha() and word.isalpha()):

If yes, it prints None

       print("None")

This is executed for valid parameters

   else:

If the character is not present, this is executed

       if word.find(chr) == -1:

           print(chr+" is not in "+word)

If the character is present, this is executed

       else:

           print(chr+" is in "+word)

The main begins here

This gets the character

chr = input("Character: ")

This gets the word

word = input("Word: ")

This calls the method and prints the required output

print(charInWord(chr,word))

What are some common uses of Excel?

Answers

Answer:

to make a spread sheet and to make sure you have all of the sum and didn[t miss a number

Explanation:

Rupesh wants to try programming with Eclipse. What is the first step he should take to make that happen?


download the Eclipse IDE

download the current Java Development Kit

create a restore point

disable his security program

Answers

Answer:

create a restore point

Explanation:

what is memory address map​

Answers

the mapping between loaded executable or library files and memory regions, these are used for resolving memory addresses

PLEASE SOMEONE ANSWER THIS
If the old code to a passcode was 1147, and someone changed it, what would the new code be?

(I already tried 4117)



[I forgot my screen time passcode please someone help I literally can’t do anything on my phone.]

Answers

Answer:

Any of these?

Explanation:

1147. 4117. 7411

1471. 4171

1714. 4711

1741. 7114

1417. 7141

Answer:

1417

Explanation:

Suppose you have a sentineled, doubly-linked list class as specified in project 2 and an object of that class called my_list. The function below finds and returns the first index of a specified value in that list, but portions have been removed. Using the minimum possible spacing at all in your answers, fill in the missing code. This algorithm does not employ the __iter__ and __next__ methods of the Linked_List class. Also note that this exercise does not include the object names, so your answers should include my_list. as appropriate. Finally, none of your responses should contain colons. As a reminder, the linked list implementation provides the following methods: insert_element_at(value, index) #cannot be used to append
append_element(value)
get_element_at(index)
remove_element_at(index)
__len__ #support for the len method to obtain the list's size
def index_of(my_list, val):
for k in :
if :
raise ValueError
and what is the performance?

Answers

Answer:

def index_of (my_list, val):

  for k in range(my_list.__len__):

      if my_list.get_element_at(k) == val :  

          return k

Explanation:

The python function "index_of" accepts two arguments, a list and the value to be searched for.

The for-loop iterates over the list using the "__len__" magic method to return the index of the searched term in the list if present.

Write a program that will read two floating point numbers (the first read into a variable called first and the second read into a variable called second) and then calls the function swap with the actual parameters first and second. The swap function having formal parameters number1 and number2 should swap the value of the two variables

Answers

Answer:

In Python:

def swap(number1,number2):

   a = number1

   number1 = number2

   number2 = a

   return number1, number2

   

first = float(input("First Number: "))

second = float(input("Second Number: "))

print("After Swap: "+str(swap(first,second)))

Explanation:

The swap function begins here

def swap(number1,number2):

This saves number1 into variable a

   a = number1

This saves number2 into number1

   number1 = number2

This saves a (i.e. the previous number1) to number2

   number2 = a

This returns the numbers (after swap)

   return number1, number2

   

The main begins here

The next two lines prompt the user for first and second numbers

first = float(input("First Number: "))

second = float(input("Second Number: "))

This calls the swap function and print their values after swap

print("After Swap: "+str(swap(first,second)))

What is the most likely reason a user would export data with the formatting in place?

A) The fields will not have any errors.

B) The file will be much easier to read.

C) The file is automatically spellchecked.

D) The columns are automatically alphabetized.

Answers

Answer:

its d

Explanation:

Answer:

its b on edge

Explanation:

believe me if youre a viber

a worldwide system of computer network​

Answers

Answer:

The internet is a worldwide system of computer network.

Define the Database ​

Answers

A structured base in a computer

Select the correct statement(s) regarding direct sequence spread spectrum (DSSS) and orthogonal frequency division multiplexing (OFDM).
a. OFDM is not classified as a spread spectrum technique, although OFDM has the effect of spreading the signal over a larger frequency spectrum
b. OFDM has greater spectral efficiency compared to DSSS
c. DSSS relies upon a PN code that is only shared by the transmitter and receiver pair
d. all statements are correct

Answers

Answer:

a. OFDM is not classified as a spread spectrum technique, although OFDM has the effect of spreading the signal over a larger frequency spectrum.

Explanation:

Orthogonal Frequency Division Multiplexing is a technique in which large digital data is sent over radio waves by splitting it into multiple subcarriers. The data is then transmitted to different users who can access the files. OFDM is not a spread spectrum technique, it is based on large frequency spectrum.

Which steps will import data from an Excel workbook? Use the drop-down menus to complete them.
1. Open the database.
2. Click the *BLANK*
tab.
3. In the import & Link group, click *BLANK*
4. Click *BLANK* to locate a file.
5. Navigate to and open the file to import.
6. Select the Import option.
7. Click OK.
8. Follow the instructions in the wizard to import the object.

Answers

Answer:

what are the blank options

Answer:

The answer is

1. External Data

2. Excel

3. Browse

Explanation:

EDGE 2021

Jobs with only 7 letters

Answers

Answer:

nursing

Explanation:

it's needs 20 words so don't mind thisssss part hehe

Answer: Teacher!!!!!!

Which of the following characterizes how an enabled security program might react to a new program installation on a computer system?


It might alert you to space requirement excesses.

It might report an error or tell you that the file is corrupted.

It might protect the new installation from getting viruses.

It might automatically set a restore point for the computer system.

Answers

Answer:

It might automatically set a restore point for the computer system

Answer:

It might report an error or tell you that the file is corrupted.

Explanation:

Other Questions
Write the fraction product of a whole number and a unit fraction. 5/12 Which literary device is used in the FIRST line ?A. Alliteration B. Metaphor C. Simile D. Personification Evaluate the equation.3/4m = 2 3/4A) m=1 9/24B) m=3 2/3C) m=3 3/4D) m=4 2/3 Who here knows Gacha Club? If you do, please rate my ocs 1-10 (NO I am not some 11 yr old who plays dress up games this is a trend so I wanted to try it):The 2 on the left are Nia and Kate (green hair), the one in the middle is irl me, and the one on the right is Mizuki. What is the perimeter of a square whose area is 289 square feet?A. 17 feetB. 48 feetC. 68 feetD. 73 feet What is the approximate area of the shaded sector?A. 38 cm2B. 96 cm2C. 302 cmD. 603 cm? Algebra help! If you can also explain that would be appreciated!! If not that's totally okay I just really need the help!! pls answer i beg who answers correct get 100 points The bill for dinner totaled $56 before tax and tip. The restaurant added a 6 percent sales tax. If Sandra wants to include a 16 percent tip calculated on the bill before sales tax is added, what is the total cost of the dinner?$59.36$64.96$68.32$68.86 Ben noticed oil leaks under his car. He measures the amount of oil, in milliliters, his truck loses in 24 hours. His measurements are shown below.9A) How many hours will Bens truck lose 200 milliliters of oil continuing this same pattern?9B) Enter the equation that represents the relationship between the time he measured the oil and the amount of oil lost. Use t for the time in hours and a for the amount of oil lost. NO SPACE IN BETWEEN YOUR ANSWER. How should the decimal point in 52.48 be moved to determine the product 52.48105 ? WILL GIVE BRAINIEST PLEASE ONLY ANSWER WITH AN ANSWERi need it urgently for class. Please solve the whole page Two opposite numbers are 4 units away from each other. What are the numbers? Jim gives the cashier a $20 bill at the pharmacy.Write an equation that relates the change c he gets back in dollars to the cost b, in dollars, of his purchases. Which variable represents the independent variable? How much change does he get back if his purchases total $12.83? Pls help you can even give me starters if you want!! What was the problem for the United States after the Annexation of Texas? What was the main effect of this action? Use four unit multipliers to convert 170 square yards to square inches The perimeter of a square is 64 inches Faces:13. Explain why a solution containing both NH3 and NH4Cl is less basic than a solutioncontaining only NH3 of the same concentration. Kelly sits on a rock in a field. Which of the following examples correctly name force pairs? Select all that apply.Kelly pushes on the rock, and the rock pushes on Earth.BEarth pulls on Kelly, and Kelly pulls on Earth.The rock pushes on Earth, and Earth pulls on the rockDKelly pushes on the rock, and the rock pushes on Kelly. PLZZ NEED HELP WITH THIS