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]
2 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]2 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
How do networks help protect data? -by preventing access by more than one person at a time -by restricting access to department
Whitepunk [10]

Answer:

because they have to rest

3 0
2 years ago
Read 2 more answers
Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: *
MrRa [10]

Answer:

Following are the code to this question:

b= input()#defining b variable for input character value

h= input()#defining h variable for input character value

b_width=6#defining b_width variable that holds an integer value 6

r1 = ' ' * b_width+h#defining r1 variable that calculates hash lines

r2 = b*b_width+h*2#defining r3 variable that calculates 6 asterisk and 2 hash line  

r3 = b*b_width+h*3#defining r3 variable that calculates 6 asterisk and 3 hash line

print(r1)#print r1 variable value

print(r2)#print r2 variable value

print(r3)#print r3 variable value

print(r2)#print r2 variable value

print(r1)#print r1 variable value

Output:

please find the attachment.

Explanation:

In the given python code, three variable "b,h, and b_width" is declared, in which "b_width" holds an integer variable "6" and variable "b and h" is used to an input character value.  In the next line, "r1, r2, and r3" is declared, that holds arrowhead values which can be defined as follows:

  • In the "r1" variable, it stores space with b_width variable and one h variable value.
  • In the "r2" variable it stores b_width and 2*h variable value.
  • In the "r3" variable it stores b_width and 3*h variable value.

At the last, it prints the "r1, r2, and r3" variable value and for arrowheads,  it follows the above program code.

6 0
3 years ago
Write a program that uses an STL List of integers. a. The program will insert two integers, 5 and 6, at the end of the list. Nex
poizon [28]

Answer:

answer:

#include <iostream>

#include<list>

using namespace std;

bool Greater(int x) { return x>3; } int main() { list<int>l; /*Declare the list of integers*/ l.push_back(5); l.push_back(6); /*Insert 5 and 6 at the end of list*/ l.push_front(1); l.push_front(2); /*Insert 1 and 2 in front of the list*/ list<int>::iterator it = l.begin(); advance(it, 2); l.insert(it, 4); /*Insert 4 at position 3*/ for(list<int>::iterator i = l.begin();i != l.end();i++) cout<< *i << " "; /*Display the list*/ cout<<endl; l.erase(it); /*Delete the element 4 inserted at position 3*/ for(list<int>::iterator i = l.begin();i != l.end();i++) cout<< *i << " "; /*Display the list*/ cout<<endl;

l.remove_if(Greater); for(list<int>::iterator i = l.begin();i != l.end();i++) cout<< *i << " ";

/*Display the list*/

cout<<endl; return 0;

}

5 0
3 years ago
Read 2 more answers
Write an if-else statement that displays 'Speed is normal' if the speed variable is within the range of 24 to 56. If the speed v
kari74 [83]

Answer:

import java.util.Scanner;

public class Speed{

int speed;

public Speed(int speed){

this.speed = speed;

}

public void checkSpeed(){

if(speed >= 24 || speed <= 56){

System.out.println("Speed is normal");

}

else

System.out.println("Speed is abnormal");

}

public static void main(String...args){

Scanner input = new Scanner(System.in);

int userSpeed = 0;

System.out.println("Enter a speed: ");

userSpeed = input.nextInt();

Speed obj1 = new Speed(userSpeed)

obj1.checkSpeed();

}

Explanation:

4 0
3 years ago
Place the steps in order for creating a filter in Outlook 2016.
Kitty [74]

Answer:

the above is correct

Explanation:

5 0
2 years ago
Other questions:
  • Who are the founders of video-sharing site Dailymotion?
    7·1 answer
  • What is html?
    9·2 answers
  • The technical relationship between inputs and outputs, which is needed to understand the difference between the short run and th
    5·1 answer
  • When you want to avoid sending email that a recipient may feel their privacy has been invaded, how would you fill in the (To) bo
    13·1 answer
  • What is a traffic controller?what are its functions?
    13·1 answer
  • An F-1 ____________ may be authorized by the DSO to participate in a curricular practical training program that is an__________
    8·1 answer
  • Which engineer may design a GPS for a vehicle?
    15·1 answer
  • Explain the working principle of computer with suitable diagram​
    15·1 answer
  • A large global retail corporation has experienced a security breach, which includes personal data of employees and customers.
    5·1 answer
  • Q2: Mark True or False in the corresponding Answer sheet (0.5 point each)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!