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
F he continues to make monthly payments of $100, and makes no new purchases, how many more payments will he have to make before
castortr0y [4]

What is the interest rate?

Divide the total amount due by 100.

8 0
3 years ago
Instructions:Select the correct answer from each drop-down menu.
mario62 [17]

when using a dark background for presentations you should use bright colors to contrast with it


this makes the informations much easier to see and read for example white text on black background

6 0
2 years ago
Use the drop-down menu to complete the sentences about the benefits of flowcharts.
mojhsa [17]

Answer:

c,a,c using the drop down menus edge 2021

GOODLUCK

Explanation:

4 0
3 years ago
David Rosen is credited with the development of which of these games?
nikklg [1K]
David Rosen is the CEO and lead programmer of Wolfire games. some of their games include Overgrowth, Desperate Gods, and Receiver.
4 0
3 years ago
Ian’s photography teacher asks him to take some photos of a few different species over the weekend. Which group of photos would
alina1380 [7]
I think it’s b or d..............
5 0
3 years ago
Other questions:
  • Which cloud computing service model gives software developers access to multiple operating systems for testing?
    5·1 answer
  • A ____ database supports data distributed across several different sites.
    7·1 answer
  • What is used for World Wide Web?
    7·1 answer
  • To pinpoint an earthquake's location, scientists need information from how many seismometers?
    8·1 answer
  • Write a file path for a document file that is saved on the F drive then a folder called homework, then a folder called math. The
    12·1 answer
  • Disadvantages of Batch<br>operation system​
    5·1 answer
  • According to the "multiple-selves" theory, of an online DVD rental service could offer same-day deliveries, so that people who o
    9·1 answer
  • Which file extension indicates a text document? .ppt .tst .pdf .txt
    14·2 answers
  • NumA = 3 <br>numB = 2<br>Result = numA ** numB
    12·1 answer
  • Which of the following is NOT a factor of identifying graphic design?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!