Guest User

Untitled

a guest
Dec 25th, 2017
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. This is a test to evaluate your HTML and basic python skills. Take your time - you are free to ask people about how some bits work.
  2.  
  3. Situation:
  4. The company is developing a HTML <table> generator. Your job is to make a class for this <table> generator.
  5.  
  6. Example input:
  7. studentid.txt
  8. Student Name, Student ID, Email, Country;
  9. Alice, 555, rihbo@fjnfw.com, Hong Kong;
  10. Billy, 52266, uih@uhfuewinf.com, America;
  11. Wheatley, 3.14, nyan@cat.com, Space
  12.  
  13. The first line is the header - it defines what fields are there.
  14. The numbers of
  15.  
  16. Handling erroneous output:
  17. If the row has less items than the header: fill the missing items with a space (&nbsp;)
  18. If the row has more items than the header: raise a ValueError with the message "Too many values in row, content was {ROWCONTENT}"
  19.  
  20. Expected output: (All the results should be aligned center, this effect is not shown in the following output)
  21. Please output the result as raw, complete HTML.
  22. No title is necessary.
  23.  
  24. ================= START OF EXPECTED OUTPUT =================
  25.  
  26. studentid.txt <- Header 1, Aligned center, Bold, Underline
  27. -------------------------------------------------------------
  28. | Student Name | Student ID | Email | Country |
  29. -------------------------------------------------------------
  30. | Alice | 555 | rihbo@fjnfw.com | Hong Kong |
  31. -------------------------------------------------------------
  32. | Billy | 52266 | uih@uhfuewinf.com | America |
  33. -------------------------------------------------------------
  34. | Wheatley | 3.14 | nyan@cat.com | Space |
  35. -------------------------------------------------------------
  36.  
  37. Size of file: FILESIZEHERE
  38. MD5 Checksum of file: MD5CHECKSUMHERE
  39.  
  40. ================== END OF EXPECTED OUTPUT ==================
  41.  
  42.  
  43. All functions inside the generator class must be well-documented, including usage, parameters, and expected return result.
  44.  
  45. Hints:
  46. How to get MD5 Checksum of a file:
  47.  
  48. import hashlib
  49.  
  50. def md5file(filename):
  51. md5 = hashlib.md5()
  52. with open(filename, 'rb') as f:
  53. for chunk in iter(lambda: f.read(8192), ''):
  54. md5.update(chunk)
  55. return md5.digest()
Add Comment
Please, Sign In to add comment