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
Is Conflict Healthy ?<br>​
Vesna [10]

yes

Explanation:

because it has more things

6 0
2 years ago
Read 2 more answers
How do you create a table in an existing database on Microsoft Access?
earnstyle [38]
Hello! In order to make a table in an existing database, first, you need to open the database you want to open, and then on the create tab, go on the tables group and click table. A table will be inserted into the database and you will be able to see it in datasheet view. That will help you make the table and be able to edit as needed.

8 0
3 years ago
Read 2 more answers
Which is the most visual social media site?
Aleks04 [339]
Enge extrapolated this analysis across the 2.2 billion<span> users on Google and concluded that while the “active profiles” on Google+ amount to </span>111 million<span> users, only 6.7 million users have 50 or more posts ever, and only 3.5 million have 50 or more posts in the last 30 days</span>
3 0
3 years ago
A security analyst accesses corporate web pages and inputs random data in the forms. The response received includes the type of
leonid [27]

Answer:

Option c is the correct answer for the above question.

Explanation:

  • The vulnerability is a term that is used to state that any system has some limitation by which the system causes an error while performing the action.
  • The above question states a software and asked the action which is used by the analyst to prevent the limitation. So the system will use the input validation.
  • It is because this prevents the error. it is because this will help to proceed with the wrong or invalid information on the database and the database or system can not hold the wrong data.
  • Hence option c is the correct answer while the other option is not correct because other options can not able to fix the limitation of the above system.
6 0
3 years ago
What is stored in a source file, an object file, and his executable file?
neonofarm [45]
A source file has source code, what a human understands. It isn't compiled or linked.

An object file has compiled, but not linked intermediary code.

An executable file has compiled and linked code which is executable.
6 0
3 years ago
Other questions:
  • What shows on the web, what is behind the web (source code) and what is placed on the server (database) , is known as web source
    13·1 answer
  • Which of the following consists of electronic components that store instructions?
    10·1 answer
  • An educational institution has a number of buildings in the campus. Each building has its own independent network system, and al
    6·2 answers
  • What is Processor to Memory Mismatch problem?
    15·1 answer
  • Can someone please help me with the three questions please?
    6·1 answer
  • To ease giving access to network resources for employees, you decide there must be an easier way than granting users individual
    9·1 answer
  • You have a notebook computer and wish to connect to an IEEE 802.11n wireless network. The computer does not have a built-in wire
    11·1 answer
  • In the layers toolbar, which layer will appear in front of your game
    9·1 answer
  • 17. When an industrial electrical circuit requires a 220 VAC single phase power supply, the electric power supply circuit is nor
    7·1 answer
  • Select the correct answer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!