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
nataly862011 [7]
3 years ago
5

he function below takes one parameter: a list of strings (string_list). Complete the function to return a new list containing on

ly the strings from the original list that are less than 20 characters long.
Computers and Technology
2 answers:
Aleks04 [339]3 years ago
4 0

Answer:

def select_short_strings(string_list):

   new_list = []

   

   for s in string_list:

       if len(s) < 20:

           new_list.append(s)

   return new_list

   

lst = ["apple", "I am learning Python and it is fun!", "I love programming, it is easy", "orange"]

print(select_short_strings(lst))

Explanation:

- Create a function called <em>select_short_strings</em> that takes one argument <em>string_list</em>

Inside the function:

- Initialize an empty list to hold the strings that are less than 20

- Inside the loop, check the strings inside <em>string_list</em> has a length that is smaller than 20. If found one, put it to the <em>new_list</em>.

- When the loop is done, return the <em>new_list</em>

- Create a list to check and call the function

3241004551 [841]3 years ago
3 0

Answer:

# the solution function is defined

# it takes a list as parameter

def solution(string_list):

# an empty new list is initialized

new_list = []

# a loop that loop through the splitted_list

# it checks if the length of each string is less than 20

# if it is less than 20

# it is attached to the new list

for each_string in string_list:

if(len(each_string) < 20):

new_list.append(each_string)

# the new list is printed

print(new_list)

# the function is called with a sample list

solution(["The", "player", "determined", "never", "compromised"])

Explanation:

The program is written in Python and it is well commented.

You might be interested in
Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
sineoko [7]

Answer:

// using c++ language

#include "stdafx.h";

#include <iostream>

#include<cmath>

using namespace std;

//start

int main()

{

 //Declaration of variables in the program

 double start_organisms;

 double daily_increase;

 int days;

 double updated_organisms;

 //The user enters the number of organisms as desired

 cout << "Enter the starting number of organisms: ";

 cin >> start_organisms;

 //Validating input data

 while (start_organisms < 2)

 {

     cout << "The starting number of organisms must be at least 2.\n";

     cout << "Enter the starting number of organisms: ";

     cin >> start_organisms;

 }

 //The user enters daily input, here's where we apply the 5.2% given in question

 cout << "Enter the daily population increase: ";

 cin>> daily_increase;

 //Validating the increase

 while (daily_increase < 0)

 {

     cout << "The average daily population increase must be a positive value.\n ";

     cout << "Enter the daily population increase: ";

     cin >> daily_increase;

 }

 //The user enters number of days

 cout << "Enter the number of days: ";

 cin >> days;

 //Validating the number of days

 while (days<1)

 {

     cout << "The number of days must be at least 1.\n";

     cout << "Enter the number of days: ";

     cin >> days;

 }

 

 //Final calculation and display of results based on formulas

 for (int i = 0; i < days; i++)

 {

     updated_organisms = start_organisms + (daily_increase*start_organisms);

     cout << "On day " << i + 1 << " the population size was " << round(updated_organisms)<<"."<<"\n";

     

     start_organisms = updated_organisms;

 }

 system("pause");

  return 0;

//end

}

Explanation:

6 0
2 years ago
What is a distinguishing feature of 5G mmWave
Tatiana [17]

Answer:

Explanation:

mmWave sử dụng phổ vô tuyến tần số cao (từ 24 GHz đến khoảng 39 GHz) để hoạt động, cho phép tăng tốc độ (và thậm chí xa hơn, trong một số trường hợp) 1Gbps. Vấn đề là việc tăng tần số lên càng cao thì khả năng đâm xuyên càng kém đi và khoảng cách truyền ngắn lại, theo Qualcomm thì đôi khi chỉ cần một bàn tay chắn trước điện thoại là đủ để máy khôngBên cạnh đó, mmWave cũng có khả năng làm hao pin thiết bị hơn, ít nhất là ở thời điểm hiện tại. Theo đó, việc tải xuống nhiều dữ liệu hơn có nghĩa là CPU điện thoại của bạn sẽ hoạt động mạnh hơn, nhanh nhất có thể để xử lý tất cả và điều đó sẽ ảnh hưởng đến tuổi thọ pin nhận tín hiệu.

5 0
2 years ago
Distinguish<br> between formal and Informal<br> Information System<br> Information systems
Harlamova29_29 [7]

Explanation:

Formal; A formal information system is based on

the organization represented by the organization chart.

Informal; The informal information system is

employee based system designed

to meet personal and vocational needs

and to help in solution of work-related problems.

5 0
2 years ago
Assuming that all of the table and column names are spelled correctly, what's wrong with the INSERT statement that follows?
Whitepunk [10]

Answer:

C. The number of items in the column list doesn't match the number in the VALUES list.

Explanation:

The INSERT INTO statement is used to insert new records in a table.

<u>Syntax is as follows:</u>

INSERT INTO table_name (column1, column2, column3, ...)

VALUES (value1, value2, value3, ...);

Each column item has to match with the values to be inserted in the same order.

In the question, there are 8 column items specified whereas there are only 7 values given to be inserted.

3 0
3 years ago
A_________is an orderly collection of fact &amp; information.
sammy [17]

Answer:

C. Database

Explanation:

4 0
3 years ago
Other questions:
  • Discuss Hashing and how it is utilized within the IT industry. Also, discuss how Hashing can improve our sorting and searching r
    12·1 answer
  • Which game would be classified as an educational game
    14·1 answer
  • The function below takes a single parameter number_list which is a list that can contain integers and floats. Complete the funct
    9·1 answer
  • The indent buttons on the home tab allow you to increase or decrease paragraph indenting in increments of ____ inches.
    5·1 answer
  • Does anyone have the problem where you try to watch a video to get your answer but it brings up a thing asking your gender to ma
    6·1 answer
  • A digital designer might do computer animations for video games,<br> OA<br> True<br> OB<br> False
    12·2 answers
  • WHAT IS ONE WAY A PIVOTTABLE COULD COMBINE THE FOLLOWING DATA
    10·1 answer
  • If you hard working right now go to this EASY question
    9·2 answers
  • You can put ______ on your phone.
    10·1 answer
  • So I tried asking for help with my code on stackoverflow but the people there were very condescending and mean plus my questions
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!