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

The function below takes a string argument sentence. Complete the function to return the second word of the sentence. You can as

sume that the words of the sentence are separated by whitespace. If the sentence contains less than two words, return None. If the last character of the word you are returning is a comma, semi-colon, period, exclamation point, or question mark, remove that last character.
Computers and Technology
1 answer:
enyata [817]3 years ago
3 0

Answer:

Following are the code to this question:

def string_argument(val): #Defining a method string_argument

   w= val.split() #Define variable that split value

   if len(w) < 2: # Define condition to check value length  

       return None #return value

   if w[1][-1] in ",;.!?": #Define condition to check special character  

       return w[1][:-1] #return second word

       return w[1] # return value

print(string_argument("good morning hello?")) #call method and print return value

print(string_argument("hii morning, DEV"))#call method and print return value

print(string_argument("how are you? MR"))#call method and print return value

print(string_argument("dev lambda. Who"))#call method and print return value

print(string_argument("thanks")) #call method and print return value

Output:

None

morning

None

lambda

None

Explanation:

In the given python program, a method "string_argument" is declared, that accepts a value val in its parameter, inside the method, another variable "w" is used, that splits the argument value. In the next line, two if conditional block is used which can be described as follows:

  • In the first block, it will check the length, it is not less then 2, if this condition is true it will return none.
  • In the second if the block it will check, that variable val holds any special character in its second word so, it will return the second word.
You might be interested in
This is on zyBooks. Please write the code in C++, please!
poizon [28]

The program is an illustration of built-in functions

<h3>What are built-in functions?</h3>

They are named program statements that have a predefined purpose

<h3>The actual program</h3>

The program written in C++, where comments are used where required is as follows:

#include <iostream>

#include <cmath>

#include <ios>

#include <iomanip>

using namespace std;

int main (){

double x;

double y;

double z;

cin>>x;

cin>>y;

//This calculates the given expression

z = pow(sqrt(y),x);

cout << fixed<<setprecision(2);

cout<<z<<endl;

return 0;

}

Read more about python functions at:

brainly.com/question/14284563

7 0
3 years ago
if you had two proxy servers located in the same room, what use could you make of them? nothing create a hub sell one of the ser
Anit [1.1K]
Create a free wifi service
6 0
3 years ago
Read 2 more answers
Which of the following is an appropriale way to declinc an offer in a<br>professional environment?​
alina1380 [7]
If you’re looking for an exact answer, we weren’t given any options, but in my personal experience just explain that you appreciated them taking their time out of their day and say that you’re no longer interested in their offer.
5 0
4 years ago
Read 2 more answers
Long form of EMF and examples ​
aliya0001 [1]

Answer:

EMF: Electro-Motive force, also called emf (denoted and measured in volts), is the voltage developed by any source of electrical energy such as a battery or dynamo. ... The potential difference of electrical energy is called electromotive force or emf.

Examples; electrochemical cells, thermoelectric devices, solar cells, electrical generators, transformers, etc.

5 0
3 years ago
___________________ describes the process of combining voice, video, and data communications over a common network infrastructur
sergejj [24]

Answer:

Convergence in the context of networking.

Explanation:

6 0
2 years ago
Other questions:
  • What is the size of the key space if all 8 characters are randomly chosen 8-bit ascii characters?
    6·1 answer
  • someone who protects valuable online information, like phone numbers and passwords would be considered​
    8·1 answer
  • Which information is considered free for use?
    9·2 answers
  • A solid understanding of __________ is the foundation of verbal communication
    7·1 answer
  • In the context of intentional computer and network threats a ____ is a programming routine built into a system by its designer
    14·2 answers
  • Aaron is stating the main idea of what he read in his own words. He is _____.
    11·2 answers
  • This unit is used to print the picture on a paper
    6·1 answer
  • SOMEONE PLEASE HELP ME PLEASE HELP ME WITH THIS!!!!!
    14·2 answers
  • What Microsoft feature enables you to represent text as colorful visuals
    12·1 answer
  • Identify the following verb by number and person by checking on the appropriate boxes.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!