Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Name: module1
  3. # Purpose:
  4. #
  5. # Author: 322078569
  6. #
  7. # Created: 07/11/2014
  8. # Copyright: (c) 322078569 2014
  9. # Licence: <your licence>
  10. #-------------------------------------------------------------------------------
  11. #Exercise 1
  12. myDict = {"befreit":"liberated", "baeche":"brooks", "eise":"ice", "sind":"are", "strom":"river", "und":"and", "vom":"from"}
  13. mySent = ("vom eise befreit sind strom und baeche")
  14. for x in mySent.split():
  15. print(myDict[x], end =" ")
  16.  
  17. #Exercise 2
  18. myPara = ("Felicity WILL you look this way exclaimed Mrs Appleton you have been fidgeting all morning Felicity tore her eyes reluctantly away from the coin she was holding in her hand and tried to concentrate on her class teacher who was talking about maths – something to do with multiplication Felicity vaguely recalled she caught matts eye and they grinned excitedly at each other this was it today was the day the two best friends had been waiting for this day for what had seemed an eternity both of them had been looking at the clock every 5 minutes both willing the hands to move forwards faster so that they could be whisked off home by day")
  19. myPara = myPara.lower()
  20. paraCounter = dict()
  21. for x in myPara.split():
  22. paraCounter[x] = 0
  23. for x in myPara.split():
  24. paraCounter[x] += 1
  25. print (paraCounter)
  26.  
  27. #Exercise 3
  28. yourDict = dict()
  29. for x in paraCounter:
  30. if paraCounter[x] != 1:
  31. yourDict[x] = paraCounter[x]
  32. print (yourDict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement