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
Python;
riadik2000 [5.3K]

a = int(input("Class A tickets sold: "))

b = int(input("Class B tickets sold: "))

c = int(input("Class C tickets sold: "))

print("Total income generated: $"+str((a*20)+(b*15)+(c*10)))

I hope this helps!

4 0
3 years ago
Before entering a loop, the first input, or ____, is retrieved.
Virty [35]

Loop is a control structure that causes a statement or group of statements to repeat.Before entering a loop, the first input, or the accumulator where the total will be kept is retrieved to an initial value, usually zero.

3 0
3 years ago
Wanna be friends anyone
Klio2033 [76]

Answer:

lol nice pic sure

Explanation:

3 0
3 years ago
Read 2 more answers
Double[][] vals =
Vilka [71]

Answer:

4

Explanation:

by counting the number of the colum to. be counted well and nicely

8 0
3 years ago
Write a program that defines an interface having the following methods: addition, subtraction, multiplication, and division. Cre
Tatiana [17]

Hello, you haven't provided the programing language in which you need the code, I'll explain how to do it using Python, and you can follow the same logic to make a program in the programing language that you need.

Answer:

1. # -*- coding: utf-8 -*-

2. #Python  

3. class Calculator:

4.     def add(self):

5.         print(a + b)

6.     def sub(self):

7.         print(a - b)

8.     def mul(self):

9.         print(a * b)

10.     def div(self):

11.         print(a / b)

12.  

13. obj = Calculator()

14. choice = 1

15. while choice != 0:

16.     a = int(input("\nEnter first number: "))

17.     b = int(input("Enter first number: "))

18.      

19.     print("\n0. EXIT")

20.     print("1. DIVISION")

21.     print("2. ADDITION")

22.     print("3. SUBTRACTION")

23.     print("4. MULTIPLICATION")

24.      

25.     choice = int(input("\nEnter your choice: "))

26.     if choice == 1:

27.         obj.div()

28.     elif choice == 2:

29.         obj.add()

30.     elif choice == 3:

31.         obj.sub()

32.     elif choice == 4:

33.         obj.mul()

34.     else:

35.         break

Explanation:

  • From lines 1 to 12 we define the object with four methods, addition, subtraction, multiplication, and division. Each method contains the operation between two variables inside a print function
  • On line 13 we instantiate our class
  • On line 14 we declare the variable choice that is going to store the operation that the user wants to perform
  • On line 15 we declare a while loop, this is going to keep running the program until the user wants to exit
  • From line 16 to 18 we ask the user to enter two numbers
  • From line 19 to 24 we print the possible operation, assigning a number for each operation, this indicates to the user what number to press for what operation
  • On line 25 we ask the user for the operation
  • From lines 26 to 35 we check the user input an accordingly we call the corresponding method to performs the operation
7 0
3 years ago
Other questions:
  • Match each vocabulary word to its definition.
    14·1 answer
  • Hit and Slopes Program: A Write a program that can be used by a ski resort to keep track if local snow conditions for one week.
    15·1 answer
  • How do I logout of Brainly on mobile? When I went to settings, it had the option to log out but it was grayed out.
    14·1 answer
  • Another name for divergent boundaries that occur under the ocean is
    6·2 answers
  • Given a String variable response that has already been declared, write some code that repeatedly reads a value from standard inp
    10·1 answer
  • Sara Beth and Taylor have developed a new software that they plan to distribute for free, allowing other software professionals
    7·1 answer
  • Which of the following statements best compares and contrasts the role of editors in a television news room and editors at a new
    5·1 answer
  • Blank Are input instructions you give to a computer
    13·1 answer
  • If we need to manage a contiguous range of memory, handling requests to allocate various sized chunks, and later make those chun
    12·1 answer
  • Which combining form is spelled incorrectly? group of answer choices gynic/o carcin/o nephr/o laryng/o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!