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
Tema [17]
4 years ago
13

#Write a function called one_dimensional_booleans.

Computers and Technology
1 answer:
deff fn [24]4 years ago
5 0

Answer:

def one_dimensional_booleans(bool_list, use_and):

   

   is_all_true = True

   is_one_true = False

   

   if use_and:

       for b in bool_list:

           if b == False:

               is_all_true = False

               break

   

       if is_all_true:

           return True

       else:

           return False

   

   else:

       for b in bool_list:

           if b == True:

               is_one_true = True

               break

   

       if is_one_true:

           return True

       else:

           return False

Explanation:

Create a function named one_dimensional_booleans that takes two parameters, bool_list and use_and

Inside the function:

Set is_all_true as True and is_one_true as False. These will be used to check the list

If use_and is True, check each item in the bool_list. If one item is False, set the is_all_true as False and stop the loop. This implies that the list contains a False value. Then check the is_all_true. If it is True, return True. Otherwise, return False.

If use_and is False, check each item in the bool_list. If one item is True, set the is_one_true as True and stop the loop. This implies that the list contains a True value. Then check the is_one_true. If it is True, return True. Otherwise, return False.

You might be interested in
The process of identifying and removing logical errors and runtime errors is called ..............
9966 [12]
The process of finding and eliminating errors is called debugging.

Hope that helps
VexPlayz
6 0
3 years ago
Read 2 more answers
Meadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual
svp [43]

Answer:

Explanation:

import java.Util;

public class Eggs{

public static void main (String [] args)

{

int noOfEggs, dozen, units;

float total;

Scanner input = new Scanner(System.in);

noOfEggs = input.nextInt();

if(noOfEggs < 0)

{

System.out.print("Invalid");

}

else

{

if(noOfEggs >= 12)

{

dozen = noOfEggs/12;

units = noOfEggs % 12;

}

else

{

dozen = 0;

units = noOfEggs;

}

total = dozen * 3.25 + (units * 45)/100;

System.out.print("You ordered "+noOfEggs+" eggs.\n");

System.out.print("That's "+dozen+" dozen at $3.25 per dozen and "+units+" loose eggs at 45 cents each for a total of $"+total);

}

}

}

7 0
3 years ago
What is not true about contracts?
Brut [27]
If you sign a contract or official document with your non-dominant hand, you do not have to follow that agreement or set of rules
5 0
4 years ago
Read 2 more answers
Next
andreyandreev [35.5K]

Answer:

sampling height

Explanation:

3 0
3 years ago
How many types of sharing of Google Forms are possible?
scoray [572]

Answer:

Open a form in Google Forms.

In the top right, click More .

Click Add collaborators.

Under "Invite people," type the names or email addresses of the people you want to work with.

Click Send.

8 0
3 years ago
Other questions:
  • How many channels are in an ISDN PRI connection?
    12·2 answers
  • Please check my answer! (Java)
    8·1 answer
  • Who predicted nearly 60 years ago that the rise of electronic media would create a "global village," thereby reducing the barrie
    12·1 answer
  • Convert 15 from decimal to binary. Show your work.
    14·1 answer
  • Who designed analatic engine in the 1930's?​
    10·1 answer
  • A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
    10·1 answer
  • "What router feature provides basic security by mapping internal private IP addresses to public external IP addresses, essential
    10·1 answer
  • In the movie Charlie and The Chocolate Factory, why did Augustus Gloop go against Mr. Wonka’s instructions and drink from the ch
    15·1 answer
  • If someone wanted to talk to a financial institution representative in person they would need to _____.
    5·1 answer
  • Difference between multi-national and global company​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!