-
Notifications
You must be signed in to change notification settings - Fork 76
Homework assignments #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #NameError | ||
| def namey(): | ||
| print those | ||
|
|
||
| #TypeError | ||
| def typey(): | ||
| 'a' - 'b' | ||
|
|
||
| #SyntaxError | ||
| def synt(): | ||
| print 'synt | ||
|
|
||
| #AttributeError | ||
| def atty(): | ||
| atty.attribute | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| def grid(): | ||
| print '+', '- - - -', '+', '- - - -', '+' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '+', '- - - -', '+', '- - - -', '+' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '|', ' ', '|', ' ', '|' | ||
| print '+', '- - - -', '+', '- - - -', '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| def grid_n(n): #n rows & columns | ||
| a = ' + ----' | ||
| b = ' | ' | ||
| for i in range(n): | ||
| print a * n, '+' | ||
| print b * n, '|' | ||
| print b * n, '|' | ||
| print b * n, '|' | ||
| print b * n, '|' | ||
| print a * n, '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| def grid_nx(n,x): #n rows, x columns | ||
| a = ' + ----' | ||
| b = ' | ' | ||
| for i in range(n): | ||
| print a * x, '+' | ||
| print b * x, '|' | ||
| print b * x, '|' | ||
| print b * x, '|' | ||
| print b * x, '|' | ||
| print a * x, '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| def grid_three(n): #n characters wide/tall | ||
| x = (n - 4) / 3 | ||
| print '+', x * '-', '+', x * '-', '+', x * '-', '+' | ||
| for i in range(x): | ||
| print '|', x * ' ', '|', x * ' ', '|', x * ' ', '|' | ||
| print '+', x * '-', '+', x * '-', '+', x * '-', '+' | ||
| for i in range(x): | ||
| print '|', x * ' ', '|', x * ' ', '|', x * ' ', '|' | ||
| print '+', x * '-', '+', x * '-', '+', x * '-', '+' | ||
| for i in range(x): | ||
| print '|', x * ' ', '|', x * ' ', '|', x * ' ', '|' | ||
| print '+', x * '-', '+', x * '-', '+', x * '-', '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| def print_grid(n): #n characters wide/tall | ||
| x = (n - 3) / 2 | ||
| print '+', x * '-', '+', x * '-', '+' | ||
| for i in range(x): | ||
| print '|', x * ' ', '|', x * ' ', '|' | ||
| print '+', x * '-', '+', x * '-', '+' | ||
| for i in range(x): | ||
| print '|', x * ' ', '|', x * ' ', '|' | ||
| print '+', x * '-', '+', x * '-', '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| def ack(m,n): # m and n are integers in between 0 and 4 | ||
| if m<0 or n<0: | ||
| return 'None' | ||
| elif m is 0: | ||
| return n+1 | ||
| elif m>0 and n is 0: | ||
| return ack(m-1,1) | ||
| elif m>0 and n>0: | ||
| return ack(m-1, ack(m, n-1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| def dist(x1, y1, x2, y2): | ||
| x3 = abs(x1 - x2) | ||
| y3 = abs(y1 - y2) | ||
| z = (x3 * x3) + (y3 * y3) | ||
| return math.sqrt(z) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| def lucas(n): # return Lucas series to the 'nth' values | ||
| if n == 1: | ||
| return 2 | ||
| elif n == 2: | ||
| return 1 | ||
| else: | ||
| return lucas(n-2) + lucas(n-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| def series(n): # return Fibonacci series to the 'nth' value | ||
| if n < 2: | ||
| return n | ||
| return series(n-2) + series(n-1) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| def sum_series(l,m,n): # return the 'lth' place in the series with starting values of m and n | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might want to check for m,n < 0. And you do want to put some test code in here with "assert" statements. |
||
| if l == 1: | ||
| return m | ||
| if l == 2: | ||
| return n | ||
| return sum_series(l-2,m,n) + sum_series(l-1,m,n) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need the abs() ? you are going to square the value later...