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
What is the correct method to use Dreamweaver to find broken links and orphaned files?
Sindrei [870]

Answer: C

Explanation:

5 0
3 years ago
What is the term for the action of Brazil imposing tariffs on US imports in response to the imposed tariffs by the U.S. on Brazi
TEA [102]

I think the answer is B.

3 0
3 years ago
Why are GUI operating system more popular than CUI operating system these days?​
julsineya [31]

Answer

GUI operating system are more popular than CUI operating system because the GUI operating system is easy to use and understand because commands are graphically presented.They support extra devices and multimedia system.They support network and internet fully.They are multiuser,multitasking operating system.eg windows.

Explanation:

Hope it helps you

8 0
3 years ago
What are some “creatures/animals” that Rex imitates?
Fantom [35]
For the answer to the question above, the Rex, robot imitates the dinosaur perfectly. In terms of its structure, the robot looks like a dinosaur, and this is seen in the robot’s serrated teeth. To some extent, the robot imitates the cheetah due to its speed ability. I hope this helps.

7 0
3 years ago
The term “computer literacy” dates back to what decade? <br> 1960s<br> 1970s<br> 1980s<br> 1990s
NNADVOKAT [17]
1970-80s which is when some of the first computers were created like apple computers which looked like a giant cube and a rectangle on the side which is very different than what we have today.

Hope this helps!
3 0
4 years ago
Other questions:
  • Can someone fix this so that it only says "its a payday" on 15 and 30 and on all other days "sorry, it's not payday"
    9·1 answer
  • As the European powers grew more industrialized, their colonies became very important as sources of A)slave labor. B)raw materia
    12·2 answers
  • While ________ is centered on creating procedures, ________ is centered on creating objects. Procedural programming, class progr
    10·1 answer
  • How does form get its power natural gas
    14·1 answer
  • List the applications in the CyberOps menu.
    15·1 answer
  • Define and discuss statistical significance as it pertains to web analytics, formulate your own opinions of what this means. in
    8·1 answer
  • In this lab, you will use all of the graphics commands you have learned to create an animated scene. Your program should have a
    10·1 answer
  • Which spreadsheet toolbar displays options such as Cut and Paste?
    11·2 answers
  • Explain input device​
    9·2 answers
  • If consumers start to believe they need a product, what is likely to happen
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!