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 describes the term "false information?"
pav-90 [236]
Inaccurate and misleading
3 0
4 years ago
The Word program window contains many elements used to create and navigate a document. List five elements of the Word program wi
Veseljchak [2.6K]

Answer:

1. Insert a table

2. Setting margins

3. Spelling and grammar correction

4. Header and footer

5. Search a word

Explanation:

1) A table can be inserted in a word document to manage data easily and in a more presentable way.

2) Different margins can be set according to the requirement and rulers can be made visible and invisible.

3) If by chance typo errors happen, a red wavy line indicates spelling mistakes and green indicates grammar mistakes which can be corrected easily.

4) Sometimes writing some professional documents, we need some text to be visible either on top or bottom of every page of that document which can be done with the help of headers and footers.

5) By pressing Ctrl+f we can easily search for a particular word in a document.

6 0
4 years ago
can you guys plz answeer this i need help rrly bad and plz no viruses or links or answers that have nun to do with this
leva [86]

Answer:

You literally posted a download it’s too risky.

Explanation:

5 0
2 years ago
To open the dialog box for modifying styles, which step must you first complete in the Navigation pane?
castortr0y [4]
Sorry I do not know this. Maybe you can help me on it? 
7 0
3 years ago
Read 2 more answers
How technology works?
Nastasia [14]

First of all, technology refers to the use of technical and scientific knowledge to create, monitor, and design machinery. Also, technology helps in making other goods.

5 0
2 years ago
Other questions:
  • Is microsoft word the same as microsoft office?
    12·2 answers
  • While traveling in India, Sabina notes all of her daily expenses in rupees in her spreadsheet. At the end of the day, she wants
    5·2 answers
  • Your friends know that you understand a lot about computers, both the technical details of how they operate as well as informati
    12·1 answer
  • Which of the following is not a property of a WAN:
    13·1 answer
  • Which statement is true about the purpose of a work in process constraint?
    15·1 answer
  • _____ is a technique in which computers are designed with many microprocessors that work together, simultaneously, to solve prob
    15·1 answer
  • The science of networking is attributed to which government's involvement?
    11·1 answer
  • Ask the user for five-coordinate pairs. Store each pair as a tuple, and store all the pairs in a list. Print the slope between a
    13·1 answer
  • What is pseudocode? O A way of describing a set of instructions in text form using plain english O A diagrammatic representation
    13·1 answer
  • 15. How many PC’s can be connected to a UPS?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!