Python Workshops for Beginners/Saturday September 27th homework: Difference between revisions

no edit summary
imported>Ynasser
No edit summary
imported>Ynasser
No edit summary
Line 11:
 
'''Exercise 1'''
 
Write a program
Write a program that creates a dictionary with keys as the characters from ''A Midsummer Night's Dream'' and the values being the number of times each particular character had a speaking part.
 
'''Exercise 2'''
 
You must have completed exercise 1 to do exercise 2. If you cannot complete exercise 1, just make up values for dictionary and try this exercise anyway.
 
Write a program which determines the percentage of the total number of speaking parts each character had. Use the dictionary you created in exercise 1. Here's an example to make the problem more clear:
 
Suppose we had the following dictionary of characters, where the values represent the number of speaking parts each has:
<pre>
>>> characters = {Harry: 3, Hermione: 4, Ron: 5}
</pre>
 
A program which determined what percentage of the total each had might output something like this:
<pre>
Ron has 41.666% of the speaking parts.
Harry has 25% of the speaking parts.
Hermione has 30% of the speaking parts.
</pre>
 
== Wordplay Exercises ==
Anonymous user