Repository navigation
session 02 - #29
session 02#29
Conversation
codedragon
left a comment
There was a problem hiding this comment.
Nice work. I'm going to wait to review this until we have worked on this stuff in class.
| print(i) | ||
|
|
||
| if __name__ == '__main__': | ||
| FizzBuzz() |
| @@ -0,0 +1,40 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
you are getting quite ahead of yourself (or the rest of us, anyway) nothing wrong with that, but as this is a session 3 exercise -- we will review it then. (any maybe put it in a "session 3" dir to keep things straight.
I do apologize -- the first few sessions are going to feel slow for folks that have some Python experience. But not everyone is the class does have much experience with python, so we spend the first few classes on the basics to get everyone on the same page.
|
You may want to take a breather and wait for the rest of the class to catch up! |
| Print a simple grid | ||
| ''' | ||
|
|
||
| for _ in range(2): |
There was a problem hiding this comment.
nice use of the underscore.
| ''' | ||
| n is the length of the line minus the plus on the side | ||
| ''' | ||
| if n < 3: |
There was a problem hiding this comment.
you could also do this with:
n = max(n, 3)
| def gene_line(char_a, char_b, n): | ||
|
|
||
| line = char_a + ' ' + ((n - 1) // 2) * (char_b + ' ') | ||
| line = line + char_a + line[::-1] |
There was a problem hiding this comment.
you can use +=
line += char_a + line[::-1]
And very nice use of slicing to reverse the string!
|
|
||
| if __name__ == '__main__': | ||
| print(repr(example_grid.__name__)) | ||
| print(repr(example_grid.__doc__)) |
| print() | ||
|
|
||
| # Assert | ||
| assert fibonnaci(3) != fibonnaci(2) - fibonnaci(1), 'this is wrong' |
There was a problem hiding this comment.
nice use of assert message.
very nice job on the whole thing.
| print(type(rot(13))) | ||
| print(rot13('testo')) | ||
| print(rot13_reverse('Zntargvp sebz bhgfvqr arne pbeare')) | ||
|
No newline at end of file |
There was a problem hiding this comment.
this is a very nice solution.
But do make sure you understand what ord() and chr() do as well.
| Print a sequence with every other item of the initial sequence | ||
| ''' | ||
| l = len(seq) | ||
| seq_ret = seq[0:1] |
There was a problem hiding this comment.
you can do this with a step in the slice:
seq[::2]
| return a sequence with the first and last 4 items removed, | ||
| and every other item in between | ||
| ''' | ||
| return every_other_rem(seq[4:len(seq) - 4]) |
There was a problem hiding this comment.
you do this with the step in the slice right here.
| ''' | ||
| l = len(seq) | ||
| seq_ret = seq[l - 1:l] | ||
| for i in range(l - 1, -1, -1): |
There was a problem hiding this comment.
this is a for loop -- not "just" slicing!
you did this in the print_grid exercise....
| if __name__ == '__main__': | ||
|
|
||
| functions = [exch_first_last, every_other_rem, first_last_in_bet, reverse_slic, third] | ||
| test_lst = ['', 'tesu', 'ab',''.join(map(str,list(range(10)))), [1,2,3], list(range(24)), list(range(9)),['1third', '2third', '3third'], []] |
These are the first 2 exercises.
Second pull request mostly to test the workflow and get your feedback
thank you
G.