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
How Oracle 12c advances the security discussion?
krok68 [10]

Answer: The oracle 12 c advances are given below.

Explanation:

The oracle 12 c provides the ability to tag the data with the label of data. It provides the classification to the data. This allows to check which data is sensitive and also allows the combination of sensitive data to be combined with the same table as the bigger data without compromising the security of the database.

8 0
4 years ago
Why was unicode invented
GrogVix [38]
The old system, ASII, was no where near large enough to deal with all the different languages & symbols that exist  
5 0
3 years ago
Read 2 more answers
Which Internet connection can have speeds around 1 Gbps?<br> Cable<br> DSL<br> Fiber<br> Satellite
Alexus [3.1K]
<h2>Answer:</h2>

<u>Fiber</u> Internet connection has speeds around 1 Gbps.

<h2></h2><h2>Explanation:</h2>

Fiber Internet connection is the modern way of transmitting and receiving data. As obvious from the name Optical Fiber consists of thin fibers that are extremely thin (as a human hair). They transmit data with the beam of light that make this transmission speedy as well as reliable. Therefore they provide  the download speed ranging from 25 Mbps to 1 Gbps.

Fiber Internet connection is considered best for the small businesses as it provides high bandwidth for transmission.  The best part of this connection is that it is made of glass and plastic that  do not conduct heat or electricity that means the fiber is safe from the damages as well.

<h3>I hope it will help you! </h3>
5 0
4 years ago
Q) Select the two obstacles for data parsing
fgiga [73]

Answer:

A and B

Explanation:

parsing with a rich grammar like TAG faces two main obstacles: low parsing speed and a lot of ambiguous syntactical parses.

3 0
4 years ago
Read 2 more answers
A friend a just opened his own barber shop and has asked you to develop a program to track the type of service the customer is r
True [87]

Answer:

class Barber(object):

   barber_shop = "Big AI's barber shop"

   def __init__(self, customer_name, type_of_service=[], tip=0):

       self.cust_name = customer_name

       self.tos = type_of_service

       self.tip = tip

   def service_type(self, *args):

       for i in args:

           self.tos.append(i)

   def total(self):

       

       services = {'trimming':10, 'hair_cut':20, 'shaving':15, 'washing':5, 'dyeing':5}

       contain = ''

       total = 0

       for service in self.tos:

           if service in services.keys():

               total += services[service]

               contain += f'{service}: {services[service]}\n'

       

       print(self.barber_shop,'\n', self.cust_name,'\n', 'Services:',contain.splitlines(),'\n', \

           f'total: ${total}', '\n',f'Tip: ${self.tip}')

mycust = Barber('John',['washing'],6 )

mycust.service_type('shaving', 'dyeing')

mycust.total()

Explanation:

The Barber class is a blueprint used to create an object instance of customers that visits the barber-shop. It has two methods 'service_type' and 'total' which are just defined functions of the class that appends services to the type of service variable and total that prints the total cost of services on the screen.

4 0
3 years ago
Other questions:
  • The indent buttons on the home tab allow you to increase or decrease paragraph indenting in increments of ____ inches.
    5·1 answer
  • The Florida PanHanble has almost 60 different types of habitats. Bases on this fact, which statement best describes the Florida
    7·1 answer
  • A company is in the middle of an operating system update to Windows 10 from Windows XP, Windows 7, and Windows 8.x. The diverse
    5·1 answer
  • which artists work provides visual effects to enhance the action of an animated movie , film, or video
    11·1 answer
  • Write a Python program to balance a checkbook. The main function needs to get the initial balance, the amounts of deposits, and
    5·1 answer
  • What computer would I need to set up my oculus quest 2 aka make my oculus quest 2 link to a computer?
    7·2 answers
  • You are between flights at the airport and you want to check your email. Your wireless settings show two options:
    14·1 answer
  • HOW TO CHANGE GRADE IN SKYWARD!!
    10·1 answer
  • What is a megavirus in computing
    8·2 answers
  • Why ads on this app do it help pay for the free stuff?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!