-6

I have to create a program for the following:

Create a function in Python named vote_pourcentage which takes as input a string and counts the number of yes and no in this chain . There It should return the percentage of yes from all yes and no , not counting abstentions in the string. ( It may be considered that the string only contains yes, no or abstention and there is at least one yes or no ).

In the main part of the Python program , ask the user to insert the string characters , invoke the vote_pourcentage function and display the result of the vote. There are many messages to display.

  1. If all votes are yes (excluding abstentions), print unanimously
  2. if at least 2/3 of the votes are yes, print clear majority
  3. and if at least half of votes are yes , print simple majority;
  4. otherwise print the motion does not pass.
Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Eli
  • 9
  • 3

1 Answers1

3

Way you can start is to split your exercise into logical parts and use google (or SO search) to solve each part.

For example,

Create a function in Python named vote_pourcentage which takes as input a string and counts the number of yes and no in this chain .

"python create function": How to define and call function

"python count in string": Count number of occurrences of a given substring in a string

There It should return the percentage of yes from all yes and no , not counting abstentions in the string.

"python count percentage": Calculate Percentage

and so on.

Community
  • 1
  • 1
Mikhail Gerasimov
  • 36,989
  • 16
  • 116
  • 159