answer.
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
lisabon 2012 [21]
2 years ago
13

The function below takes a single string parameter: sentence. Complete the function to return a list of strings that are in the

sentence that contain a lowercase letter 'a'. Hint: you may find the split method and in operator useful in solving this problem.

Computers and Technology
1 answer:
trasher [3.6K]2 years ago
4 0

Answer:

#section 1

def listofWordswitha(text):

   ''' This function prints out every word in a string with the letter 'a' '''

   tex = text.split()

   new = []

#section 2

   for word in tex:

       for char in word:

           if char == 'a':

               new.append(word)

               

               break

   return new

Explanation:

#section 1

You must first define your function and give it one argument that represents the the string that you will pass to it.

It is always good to have a doc-string that tells you what a function does, so i have also included one.

Next, you split the string using the split method that creates a list out of a string. Finally in this section you create a new list that will hold all the values with 'a'.

#section 2

The choice of words used here are intentional to make it easy to understand.

FOR every WORD in the list and FOR every CHARACTER in the WORD.

IF there is a CHARACTER 'a' contained in the word, ADD that WORD to the NEW LIST.

the append method is used to add new words to the list.

A break is used to ensure we don't have any duplication because some words can have two or more occurrence of 'a' in them. so whenever the loop sees a word with 'a', it appends it and moves to the next word.

Lastly, we return the new list.

I will take your question and use it to test the code and attach the results for you.

You might be interested in
Enter an input statement using the input function at the shell prompt. When the prompt asks you for input, enter a number. Then,
Pavel [41]

Answer:

<u>Explanation:</u>

An input statement using the input function at the shell prompt is as follows:

If a prompt asks for a input, a number is to be added

num = input ('Number: ')

num = num + 1

print(num)

Explanation of results: This gives error at line num= num + 1 as cannot convert int object to str implicitly

8 0
2 years ago
1. The precious metals needed to make computer chips, graphic cards, and transistors are found in only a small population of cou
dexar [7]

Answer:

it means that they can charge companies to come mine it making them more wealthy they can also upscale the materials needed to make it as they are the only countries that sell it so they have no one to compete with

3 0
2 years ago
In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
MAVERICK [17]

Answer: themes

Explanation:

Took the test

3 0
2 years ago
Of 500 sessions that occurred on a website during a one-week period, 200 of them started on the homepage; 100 of these 200 sessi
Elena L [17]

Answer:

the homepage bounce rate

Explanation:

Bounce rate is defined as the percentage of people that visits a page on a website and then exit or leave. That is, the visitors did not view any other page except the first one and they just leave the page after that visit. In order to get the bounce rate, the total number of visitors to a single page is taken and its then divided by the total number of visits to the website. For example, if the total number of visitors to a website over a period of time is 3000, while those that only visited a page on the website is 500, then the bounce rate is

(500/3000) * 100 = 16%

For this question, the homepage recorded 100 visited only once out of 200 which means homepage bounce rate is 50% : (100/200)*100

While website bounce rate is total number of bounces across the website/total visit to the website

100+100 =200 this is the total bounces across the website

200/500 :500 is the total visit to the website

(200/500)*100 = 40 %

Therefore the homepage bounce rate is higher than the site bounce rate

7 0
2 years ago
Which of the following is considered technology?
nevsk [136]
A. computer
computer because computer is technology and pencil is not and spoon.
8 0
2 years ago
Other questions:
  • The adjusted cell references in a copied and pasted formula are called ____ cell references.
    7·1 answer
  • Kyle took a photograph of his sister, but he later noticed that his lens was marginally out of focus. Which tool can he use to i
    15·1 answer
  • The navigation bar on the left side of ____ view contains commands to perform actions common to most office programs.
    15·1 answer
  • Zander is beginning to take college courses to prepare for a career in computer science, which is the study of using logic to cr
    5·1 answer
  • A form that dedicates a page for each item retrieved for a case; it allows investigators to add more detail about exactly what w
    10·1 answer
  • Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
    15·1 answer
  • To be eligible for the leadership training program offered by the office, a student must have at least 2 years of post-secondary
    9·1 answer
  • print_pattern() prints 5 characters. Call print_pattern() twice to print 10 characters. Example output: ***** ***** in python
    7·1 answer
  • php Exercise 3: Function Write a function named word_count that accepts a string as its parameter and returns the number of word
    5·1 answer
  • What is the function of napier's bones<br>​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!