Repository navigation
Session03 and 04 activities - #81
Conversation
|
Kat -- you've been busy! There is a lot here -- anything in particular you would like reviewed? |
|
Took the grammer to a level beyond for fun. The mailroom program and most
session04 labs would be sufficient, thanks!
…On Fri, Oct 27, 2017 at 9:50 PM, Christopher H.Barker, PhD < ***@***.***> wrote:
Kat -- you've been busy!
There is a lot here -- anything in particular you would like reviewed?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#81 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARwbqDlBMS4xu2zBD7kRiCuopmgkgmfmks5swrJ4gaJpZM4QJpTv>
.
|
PythonCHB
left a comment
There was a problem hiding this comment.
This is some really nice work!
Great to see you get into the projects.
| 'Benedict Cumberbatch': [200000.0], | ||
| 'Elon Musk': [10000.0, 150000.0, 100000.0], | ||
| 'Dad': [20.0, 5.0], | ||
| 'Donald Trump': [2.81], |
There was a problem hiding this comment.
generous donor, that Trump guy :-)
|
|
||
|
|
||
| def update_widths(line): | ||
| """ Updates minimum column widths based on |
There was a problem hiding this comment.
getting fancy here! nice!
| 'Donald Trump': [2.81], | ||
| 'Billy Neighbor': [.54, .01, .25]} | ||
|
|
||
| COLUMN_WIDTHS = [0] * 4 |
There was a problem hiding this comment.
I wonder if it's worth having this as a global, rather than simply re-creating it when you need it.
| options = { | ||
| '1': { | ||
| 'prompt': 'Send a Thank You', | ||
| 'module': print_thank_you}, |
There was a problem hiding this comment.
you probably want to use the word "function" or "operation" or "action", or.... "module" has a specific meaning in Python.
nice structure though!
| while True: | ||
| print('Please choose from the following options:') | ||
| prompt = '\n'.join(['{} {}'.format( | ||
| option, options[option]['prompt']) for option in options]) |
There was a problem hiding this comment.
really slick!
one hint -- if you want both the key and the value in a dict, you can use items():
['{} {}'.format( option_num, option['prompt']) for option_num, option in options.items()]
| print('\tSYSTEM RESULT: {}'.format(result)) | ||
| print('\tANSWER: {}'.format(answer)) | ||
| else: | ||
| print('passed {} module'.format(module.__name__)) |
There was a problem hiding this comment.
You've got slicing down --nice work!
|
|
||
|
|
||
| def pad(integer, length): | ||
| """ Pads given integer as string with 0s up to given length. |
There was a problem hiding this comment.
everything in this lab can be done pretty directly with the right formatting specifier..
| """ | ||
| if not tup: | ||
| return 'no numbers' | ||
| output = 'the {:d} numbers are: ' + ', '.join(['{:d}'] * len(tup)) |
| s4 = {i for i in range(21) if i % 4 == 0} | ||
| print('s2:{}'.format(s2)) | ||
| print('s3:{}'.format(s3)) | ||
| print('s4:{}'.format(s4)) |
There was a problem hiding this comment.
when it's this simple -- not much need for the format string:
print("s4:", s4)
|
|
||
| with open(path_to_file, 'r') as f: | ||
| f.readline() | ||
| for line in f.readlines(): |
There was a problem hiding this comment.
for line in f:
does the same thing, but without loading it all into memory first.
No description provided.