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
jenyasd209 [6]
3 years ago
12

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 and that there are at least two words in the sentence. You don't need to worry about removing any punctuation. (python)
def return_second_word(sentence):
Computers and Technology
1 answer:
Soloha48 [4]3 years ago
4 0

Answer:

Following are the program in the Python Programming Language.

# define function.

def return_second_word(sentence):

 #remove all the spaces from the sentence

 sentence=' '.join(sentence.split())

 #the list is split from spaces

 my_list = sentence.split(" ")

 #return the list

 return my_list[1]

#define main function

def main():

 #get input from the user

 se = input("Enter the sentence: ")

 #print and call the function

 print(return_second_word(se))

#condition to execute the main function

if __name__ == "__main__":

 #call main function

 main()

<u>Output:</u>

Enter the sentence: I love python

love

Explanation:

Here, we define the function i.e., "return_second_word()" and pass an argument "sentence", inside the function.

  • Remove all the spaces from the variable "sentence" and again store in the variable "sentence".
  • Set the variable "my_list" that store the split value of the variable "sentence".
  • Return the list and close the function.

Finally, we define the main function and inside the main function.

  • Get input from the user in the variable "se"
  • And pass the variable "se" in the argument list during the calling of the function "return_second_word()".
  • Then, print and call the function "return_second_word()".
  • Set the if statement to call the main function then, call the main function.
You might be interested in
Business: check ISBN-13) ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d12d13.
alexandr1967 [171]

Answer:

Following are the code to this question:

#include <iostream>//defining header file

#include <string.h>//defining header file

using namespace std;//using package

char checksum(const char *x)//defining a method checksum  

{

int s=0,m,d;//defining integer variables

for (m= 1;*x;++x)//defining for loop for caLculate value

{

d=*x-'0';//use integer variable to remove last digit from input value  

s=s+m*d;//add value in s variable

m=4-m;//use m to remove 4 from m

}

return '0'+(1000-s)%10;//use return keyword to get value  

}

int main()//defining main method

{

char ISBNNum[14];// defining character array  

cout<<"Enter the first 12 digits of an ISBN-13 as a string:";//print message

cin>>ISBNNum;//input value from user end

if(strlen(ISBNNum)==12)//defining if block to check length

{

char a=checksum(ISBNNum);//defining char variable a to call method checksum

ISBNNum[12]=a;//use array to hold method value

ISBNNum[13]='\0';// use array to hold 13 character value

cout<<"The ISBN-13 number is "<<ISBNNum;//print number

}

else//defining else block

{

cout<<ISBNNum<<" is an invalid input"<<endl;//print message

}

return 0;

}

output:

please find the attachment.

Explanation:

In the given code a character method "checksum" is define that accepts a character as a parameter and inside the method, three integer variable "s,m, and d" is defined that uses the for loop to calculate the input value and use the return keyword for the return value.  Inside the main method, a char array "ISBNNum", is defined that input the value from the user-end and define the conditional statement.

  • In the if block, it uses "ISBNNum" char array that checks its length equal to 12, if this condition is true it defines char a to call the method and hold its value and use the array to sore value in a and its 13 lengths it stores "\0", and print its value.
  • If the condition is false, it will print input array value and print invalid input as a message.

8 0
4 years ago
How to add if an statemement on a retrun in react js.
miv72 [106K]

Answer:

Of course, if we think about if statement in Javascript or Typescript logic, it’s the same as in every Javascript or Typescript place.

It’s just if/else like pure javascript, but in this case, we won’t talk about the normal if/else.

In react, we’ll need if statements for the one more thing, it’s the rendering.

It’s named “Conditional rendering”, but to make it simple, let’s stay with “if statement in react”.

There are the two most popular ways to use conditional rendering that we’ll see in the React.js code, and depends on a case, both of them are correct.

The first way that we can use is to define the conditional rendering directly in the components layout.

It’s quick and easy that we’ll use the most, and in some cases, it is the best for performance.

We’ll be using this way in the cases when we have only one condition, more just as “if”, when we would like to render some element when a specified condition is passed.

The second way is the function created to handle specified parts of the layout, and render it conditionally, to do that we can use not only if/else but the switch case as well.

This one way is right to use in cases where we have more conditions, especially the version with switch one.

But it fires the function anyway, so it is no sense to use it when we have one condition.

Let’s take a look at the code examples where I added both ways of doing that:

// The first example with the code inside functional component

function Parent(props) {

 return(

   <>

     {name === "Duomly" && (

       <DuomlyComponent/>  

     )}

   </>

 )

}

// The second example with the additional function

function renderComponent() {

 const name = 'Duomly';

 if (name === 'Duomly') {

   return 'Duomly';

 } else {

   return null;

 }

}

function Parent(props) {

 return renderComponent();

}

Explanation:

3 0
3 years ago
Why does my playstation keep disconnecting from wifi?.
REY [17]

Answer:

because there might be a internet

problem

Explanation:

5 0
2 years ago
Select the correct answer. Arcade games such as Donkey Kong, Mr. Do! , and Venture were adapted from arcade titles to home conso
Andrew [12]

Answer:

D. Magnavox

hgjvyihbnjbuhklnk. hvgvjnm;lkbhkvkbl.

4 0
4 years ago
Two devices are connected to the Internet and communicating with one another. A squirrel chews through one of the wires in the n
bearhunter [10]

Answer:

Fault-Tolerance

Explanation:

Fault tolerance refers to the ability of a system (computer, network, cloud cluster, etc.) to continue operating without interruption when one or more of its components fail.

5 0
4 years ago
Other questions:
  • A(n)…………is the interface used toconnect external devices to the computer.
    5·1 answer
  • Ann, a user, reports that she is no longer able to access any network resources. Upon further investigation, a technician notice
    8·1 answer
  • Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia"). Assume also that stdin is a v
    9·1 answer
  • Someone claims that the big O notation does not make sense at all, and they give the following example. An algorithm A that proc
    15·1 answer
  • How are the monsters related to humans
    5·1 answer
  • When you expand the virtual size of a game, what do you create?
    7·1 answer
  • Choose the correct term to complete the sentence.
    12·1 answer
  • Why linked list is better than an array?
    7·1 answer
  • What is the difference between DWT and CWT?
    11·1 answer
  • Before a computer can use a router, what configuration information must it be provided?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!