Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

session 02 - #29

Merged
PythonCHB merged 19 commits into
UWPCE-PythonCert:masterfrom
guillaumethomas:master
Oct 13, 2017
Merged

PythonCHB merged 19 commits into
UWPCE-PythonCert:masterfrom
guillaumethomas:master

Conversation

@guillaumethomas

Copy link
Copy Markdown
Contributor

These are the first 2 exercises.
Second pull request mostly to test the workflow and get your feedback

thank you

G.

@codedragon codedragon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@@ -0,0 +1,40 @@
#!/usr/bin/env python3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@PythonCHB

Copy link
Copy Markdown
Contributor

You may want to take a breather and wait for the rest of the class to catch up!

@PythonCHB PythonCHB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

Print a simple grid
'''

for _ in range(2):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice use of the underscore.

'''
n is the length of the line minus the plus on the side
'''
if n < 3:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the repr?

print()

# Assert
assert fibonnaci(3) != fibonnaci(2) - fibonnaci(1), 'this is wrong'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'], []]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@PythonCHB
PythonCHB merged commit c17c998 into UWPCE-PythonCert:master Oct 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants