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
mart [117]
3 years ago
15

Define a function begins_with_line that consumes a string and returns a boolean indicating whether the string begins with a dash

('-') or a underscore '_'. For example, the string "-Yes" would return True but the string "Nope" would return False. Note: Your function will be unit tested against multiple strings. It is not enough to get the right output for your own test cases, you will need to be able to handle any kind of non-empty string. Note: You are not allowed to use an if statement.
Computers and Technology
1 answer:
Ksju [112]3 years ago
8 0

Answer:

The program written in python is as follows:

def begins_with_line(userinut):

     while userinut[0] == '-' or userinut[0] == '_':

           print(bool(True))

           break;

     else:

           print(bool(not True))

userinput = input("Enter a string: ")

begins_with_line(userinput)

Explanation:

The program makes use of no comments; However, the line by line explanation is as follows

This line defines the function begins_with_line with parameter userinut

def begins_with_line(userinut):

The following italicized lines checks if the first character of user input is dash (-) or underscore ( _)

<em>      while userinut[0] == '-' or userinut[0] == '_': </em>

<em>            print(bool(True))  </em><em>->The function returns True</em>

<em>            break; </em>

<em>However, the following italicized lines is executed if the first character of user input is neither dash (-) nor underscore ( _)</em>

<em>      else: </em>

<em>            print(bool(not True))  </em><em>-> This returns false</em>

The main starts here

The first line prompts user for input

userinput = input("Enter a string: ")

The next line calls the defined function

begins_with_line(userinput)

<u><em>NB: The program does not make use of if statement</em></u>

You might be interested in
Which of the following software costs money?
loris [4]
Word 2013. Google docs is free on the web. OpenOffice Writer is a free version on word. Word Online is a free version of word on the web. And Word 2013 cost $200 dollars for just word :-). Oh yeah, the whole office suit is around $300!
7 0
4 years ago
Read 2 more answers
What read a page on website​
katovenus [111]

Answer:

Dino

Explanation:

3 0
3 years ago
Which of these purchases is most likely to be paid for with a credit card
Vesna [10]

Answer:

plane ticket?

Explanation:

7 0
3 years ago
Which of the following documents specifies the uptime guarantee of a web server?A. Due processB. Due diligenceC. Scope of workD.
Harrizon [31]

Answer: D) Service Level Agreement.

Explanation: A service Level Agreement, also known by the acronym SLA, is a written agreement between a service provider and its customer in order to set the agreed level for the quality of such service. The SLA is a tool that helps both parties reach a consensus in terms of the level of service quality, in aspects such as response time, time availability, available documentation, personnel assigned to the service, among others.

6 0
3 years ago
You can use the ____ utility to zero in on the service or other program that is slowing down startup. 1. gpupdate 2. MSconfig 3.
Step2247 [10]
I'd say MSconfig, you can use that and view the 'processes' tab, but it will make you open up the task manager.
3 0
3 years ago
Other questions:
  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
    15·1 answer
  • Splunk uses ________ to categorize the type of data being indexed..
    11·2 answers
  • What are some objects in your home that demonstrate electrical energy to radiant energy to thermal energy
    10·2 answers
  • In the movie, Willy Wonka and the Chocolate Factory, Augustus Gloop leans over the chocolate river to get a drink and falls in.
    11·1 answer
  • Ellen has eggs she wishes to trade for grain. However, she cannot find anyone with grain that needs eggs. What is missing for th
    14·1 answer
  • Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components o
    5·1 answer
  • Write short notes about monitor printer and speaker​
    14·2 answers
  • Rebbeca has finished with the research and outline portion of her slide presentation. Now, the next logical step is to begin wor
    11·1 answer
  • what stage is the most inner part of the web architecture where data such as, customer names, address, account numbers, and cred
    11·1 answer
  • Any computer expert to help me answer this question plz am giving brainliest
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!