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
When you are typing data that is in a series, such as days of the week or months of the year, you can use this tool to complete
sertanlavr [38]

Answer:

Days of the week including weekends Fill Weekdays – you can autofill working days of the week excluding weekends. This is very cool. I can autofill dates excluding the weekends. Fill Months – and you can use the full word or a standard abbreviation for the month, and Excel will autofill the sequence.

Explanation:

3 0
2 years ago
Energía de movimiento de los átomos o moléculas
olasank [31]

Answer:

g

Explanation:

4 0
2 years ago
I have a question about this programming assignment. The outcome when the user puts in Taylor for guest one and Fernando for gue
ivolga24 [154]
Yes u need more brackets
4 0
3 years ago
Read 2 more answers
You're using disk management to view primary and extended partitions on a suspect's drive. the program reports the extended part
kodGreya [7K]

The best assumption to make is that there is a hidden partition and the drive needs to be further searched.

5 0
3 years ago
KSJEDHGYGVWJHMJ,RHGFYDOYWUGWHBJK
Sophie [7]

Answer:

hmmm this seems sophisticated.

Explanation:

4 0
2 years ago
Other questions:
  • What was the first browser that allowed for graphics to be viewed on the web?
    14·2 answers
  • <img src="https://tex.z-dn.net/?f=3x%20-%205%20%3D%203x%20-%207" id="TexFormula1" title="3x - 5 = 3x - 7" alt="3x - 5 = 3x - 7"
    12·1 answer
  • Which one of the following items is an example of software?
    15·1 answer
  • If a speed mismatch was configured between two Cisco routers' Ethernet interfaces, what would the status of this interface be?
    12·1 answer
  • Which is slower RAM or the CPU?
    11·2 answers
  • Strobe lights can become more yellow as they age true or false
    8·1 answer
  • Code embedded into an HTML page and downloaded by a user; resides on the client and helps process Web form input. Common clients
    9·1 answer
  • You have invested millions of dollars for protecting your corporate network. You have the best IDS, firewall with strict rules a
    14·1 answer
  • A corporation is looking to receive approval from its shareholders. The corporation needs to communicate financial information a
    11·1 answer
  • How many residues separate amino acids that are stabilized by hydrogen bonds in α helices?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!