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
solniwko [45]
2 years ago
12

Accept total number of participants (B) in class. A group of

Computers and Technology
1 answer:
mestny [16]2 years ago
6 0

The <em>required code</em> written in python 3 which assigns participants to the <em>4 groups</em> based on the instruction given goes thus :

def assign(p):

<em>#initialize a function named assign </em><em>which</em><em> </em><em>takes</em><em> </em><em>in</em><em> </em><em>one</em><em> </em><em>argument</em><em> </em><em>which is</em><em> </em><em>the</em><em> </em><em>number</em><em> </em><em>of</em><em> </em><em>participants</em><em> </em>

if p%2 == 0 :

<em>#checks</em><em> </em><em>if</em><em> </em><em>the</em><em> </em><em>number</em><em> </em><em>of</em><em> </em><em>participants</em><em> </em><em>is</em><em> </em><em>even</em><em> </em>

val = p/4

<em>#divide</em><em> </em><em>the</em><em> </em><em>number</em><em> </em><em>into</em><em> </em><em>4</em><em> </em><em>equal</em><em> </em><em>groups</em><em> </em>

a,b,c,d = (val,val,val,val)

<em>#assign</em><em> </em><em>the</em><em> </em><em>equal</em><em> </em><em>value</em><em> </em><em>to the</em><em> </em><em>group</em><em> </em><em>’</em><em>s</em><em> </em><em>using</em><em> </em><em>tuple</em><em> </em><em>unpacking</em><em> </em>

print('Group A = %d, Group B = %d, Group C = %d, Group D = %d' %(a,b,c,d))

<em>#display</em><em> </em><em>the</em><em> </em><em>grouping</em><em> </em>

else :

<em>#if</em><em> </em><em>it</em><em> </em><em>is</em><em> </em><em>not</em><em> </em><em>even</em><em>,</em><em> </em><em>then</em><em> </em>

val = p//4

<em>#get</em><em> </em><em>the</em><em> </em><em>whole</em><em> </em><em>number</em><em> </em><em>divison</em><em> </em><em>into</em><em> </em><em>4</em><em> </em><em>groups</em><em> </em>

rem = p%4

<em>#get</em><em> </em><em>the</em><em> </em><em>remainder</em><em> </em><em>value</em><em> </em>

a,b,c,d = (val, val, val , val+rem)

<em>#assign</em><em> </em><em>the</em><em> </em><em>whole</em><em> </em><em>number</em><em> </em><em>to</em><em> </em><em>the</em><em> </em><em>first</em><em> </em><em>three</em><em> </em><em>groups</em><em> </em><em>and</em><em> </em><em>the</em><em> </em><em>sum</em><em> </em><em>of</em><em> </em><em>the</em><em> </em><em>whole</em><em> </em><em>number</em><em> </em><em>and</em><em> </em><em>remainder</em><em> </em><em>to</em><em> </em><em>the</em><em> </em><em>fourth</em><em> </em><em>group</em><em> </em>

print('Group A = %d, Group B = %d, Group C = %d, Group D = %d' %(a,b,c,d))

<em>#display</em><em> </em><em>the</em><em> </em><em>allocation</em><em> </em><em>of</em><em> </em><em>participants</em><em> </em>

Therefore, the sample run of the program is attached below.

Learn more :brainly.com/question/24895955

You might be interested in
Hello pls answer<br><br><br>what is the use of loop in java​
xxMikexx [17]
The use of loop in java is to run a block of code for a certain number of times.
7 0
2 years ago
Write a program that uses the Purchase class in 5.13. Set the prices to the following: Oranges: 10 for $2.99 Eggs: 12 for $1.69
Xelga [282]

Answer:

Explanation:

The following program is written in Java. Using the program code from Purchase class in 5.13 I created each one of the fruit objects. Then I set the price for each object using the setPrice method. Then I set the number of each fruit that I intended on buying with the setNumberBought method. Finally, I called each objects getTotalCost method to get the final price of each object which was all added to the totalCost instance variable. This instance variable was printed as the total cost of the bill at the end of the program. My code HIGHLIGHTED BELOW

//Entire code is in text file attached below.

//MY CODE HERE

       DecimalFormat df = new DecimalFormat("0.00");

       oranges.setPrice(10, 2.99);

       oranges.setNumberBought(2*12);

       eggs.setPrice(12, 1.69);

       eggs.setNumberBought(2*12);

       apples.setPrice(3, 1);

       apples.setNumberBought(20);

       watermelons.setPrice(1, 4.39);

       watermelons.setNumberBought(2);

       bagels.setPrice(6, 3.50);

       bagels.setNumberBought(12);

       totalCost = oranges.getTotalCost() + eggs.getTotalCost() + apples.getTotalCost() + watermelons.getTotalCost() + bagels.getTotalCost();

       System.out.println("Total Cost: $" + df.format(totalCost));

   }

}

5 0
2 years ago
A computer scientist creates an app that tells you a funny joke each time you touch the Joke button.
Lena [83]

Answer:

B And A

Explanation:

B: The controller renders a responce it can be seen as a manager and other parts are its workers and makes sure that other parts are "working" well

6 0
2 years ago
Which is a common problem caused by the widespread use of computers?
Andru [333]
Hacking would be a widespread problem.
8 0
3 years ago
Discuss the benefits of a system safety effort other than improved safety
klio [65]

Answer: Safety effort of system is defines as the measures that are taken to provide and maintain the protection of the system.There are several methods ,tool and efforts made for the system security .Benefits of the system security are as follows:-

  • Takes control over the hazardous situation and maintain the security
  • System security will also increase the development of the system easily.
  • Approach towards the analyzing of the system function
  • Data, information and functions are safe from being detected in unauthorized way.
  • Functions and implementation is made easy without the fear of getting attacked or hacked.

8 0
3 years ago
Other questions:
  • Describe in one or more complete sentences how someone starting a computer repair business in a town night gain a competitive ad
    15·1 answer
  • Describe the general process of creating a DataFlow Diagram (DFD)
    7·1 answer
  • Marty uses a customized database to sort parts and track inventory. The customized database is an example of _____.
    15·1 answer
  • If a driving who is under the age of 21 is stopping by a law enforcement officer and shown to here a bal of .02 or greater, he o
    14·1 answer
  • Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates R1 = 500 kbps, R2
    14·1 answer
  • if a user has one column in a table and would like to make it into two columns which command should be used
    13·1 answer
  • HELP FAST
    14·1 answer
  • Question #5
    11·2 answers
  • Can you guys help me with this coding assignments?
    10·1 answer
  • What computer is designed for particular application​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!