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
A new object of type list is created for each recursive invocation of f.A. TrueB. False
sammy [17]

Answer:

True but double check!

7 0
3 years ago
For which firewall feature should you create forward trust and forward untrust certificates?
guajiro [1.7K]

Answer:Jun 19, 2019 - Additionally, set up a forward untrust certificate for the firewall to ... After setting up the forward trust and forward untrust certificates required for SSL Forward Proxy ... If you do not install the forward trust certificate on client systems, ... Create a Decryption Policy Rule to define traffic for the firewall to decrypt.

WELCOME

8 0
3 years ago
My laptop is 20℅ charged and then i shut down it . I dont turned it on for 2 days and also donot charge it now after 2 days it i
Tju [1.3M]

Answer:

__you need to charge it__

4 0
2 years ago
A. Which feature was likely created first, Hole 1 or Extrusion 3? How do you know?
Nata [24]
<span>The feature that was likely created first is Extrusion 3 then Hole 1. It is because you cannot create a hole if the solid itself is not well defined. The plane must be made into solid (thus extrusion) then create a hole.</span>
5 0
3 years ago
Write a code in C++ that can save 100 random numbers in an array that are between 500 and 1000. You have to find the average of
Anni [7]

Answer:

#include <iostream>

#include <random>

//here we are passing our array and a int by ref

//to our function called calculateAverage

//void is infront because we are not returning anything back

void calculateAverage(int (&ar)[100], int &average){

 int sum = 0;

 for(int i = 0;i < 100; i++){

   //adding sum

   sum += ar[i];

 }

 //std:: cout << "\naverage \t\t" << average;

//calculating average here

 average += sum/100;

}

int main() {

 int value = 0;

 int average = 0;//need this to calculate the average

 int ar[100];

 //assign random numbers from 500 to 1000

 //to our array thats called ar

 for(int i = 0; i < 100; i++){

   value = rand() % 500 + 500;

   ar[i] = value;

   

 }

 calculateAverage(ar,average);

 // std:: cout << "\naverage should be \t" << average;

 

}

Explanation:

not sure how else this would work without having to pass another variable into the function but I hope this helps!

I commented out the couts because you cant use them according to ur prof but I encourage you to cout to make sure it does indeed calculate the average!

3 0
3 years ago
Other questions:
  • onsider the following program: Peform a total of six exercises. Select one exercise from each of the following areas: hips and l
    6·1 answer
  • ___ is an example of a calling statement.
    6·2 answers
  • The main activity area or the brain of the computer is called the ________
    15·1 answer
  • who will follow me on tiktok and like all my videos? if you do ill give branlist and give u a shoutout and you can enter my big
    15·1 answer
  • What is the difference between paper size and page margins in word
    5·2 answers
  • Write down the bit pattern in the fraction of value 1/3 assuming a floating point format that uses Binary Coded Decimal (base 10
    10·1 answer
  • The National Archives is part of the federal government, which means that its content:
    9·1 answer
  • A _____ is sent to companies that are hiring to get an interview. résumé brochure business report newsletter plz hurry need it n
    13·2 answers
  • One of the disadvantages of cable technology is that: while it works well for television signals, it is ineffective for data tra
    8·1 answer
  • What is 11x12x12x14x15x16
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!