-
Notifications
You must be signed in to change notification settings - Fork 14
updating type hint for solutions #9
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
Open
tnguyen306
wants to merge
6
commits into
main
Choose a base branch
from
type_hinting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,18 +1,22 @@ | ||
# Author: Brandon Hoffman | ||
# Date: 10/17/2020 | ||
# Description: created a function called fib() that calculate a fibonnaci number for a given 'n' without recursion or the golden ratio. | ||
# Author: Brandon Hoffman Date: 10/17/2020 Description: created a function called fib() that calculate a Fibonacci | ||
# number for a given 'n' without recursion or the golden ratio. | ||
|
||
def fib(n): | ||
'''calculate a fibonnaci number given the input 'n' without recursion using the golden ratio''' | ||
|
||
prev_num = 0 | ||
curr_num = 1 | ||
sol = 1 | ||
for i in range(n-1): | ||
def fib(n: int) -> int: | ||
"""calculate a fibonnaci number given the input 'n' without recursion using the golden ratio""" | ||
|
||
prev_num: int = 0 | ||
curr_num: int = 1 | ||
sol: int = 1 | ||
print("The numbers in fibonacci series are : ") | ||
i: int | ||
for i in range(n - 1): | ||
sol = curr_num + prev_num | ||
prev_num = curr_num | ||
curr_num = sol | ||
|
||
|
||
print(sol) | ||
return sol | ||
|
||
|
||
number: int = int(input("Please enter a number to calculate its Fibonacci number: ")) | ||
print("The Fibonacci number is: ", fib(number)) |
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
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
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
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 @@ | ||
from Taxicab import Taxicab | ||
|
||
cab = Taxicab(3, -8) # creates a Taxicab object at coordinates (3, -8) | ||
cab.move_x(4) # moves cab 4 units "right" | ||
cab.move_y(-5) # moves cab 5 units "down" | ||
cab.move_x(-2) # moves cab 2 unit "left" | ||
print(cab.get_odometer()) # prints the current odometer reading |
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
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 |
---|---|---|
@@ -1,9 +1,22 @@ | ||
# Author: Brandon Hoffman | ||
# Date: 10/25/2020 | ||
# Description: create a function that takes a list of names and stores any value that starts with the letter 'K' in a new list concatenated also with the string ' Hoffman' | ||
# Author: Brandon Hoffman Date: 10/25/2020 Description: create a function that takes a list of names and stores any | ||
# value that starts with the letter 'K' in a new list concatenated also with the string ' Hoffman' | ||
|
||
def add_surname(name_list): | ||
def add_surname(name_list: list[str]) -> list[str]: | ||
branhoff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
takes a list of names and stores any value that starts with the letter 'K' in a new list concatenated also with the string ' Hoffman' | ||
takes a list of names and stores any value that starts with the letter 'K' in a new list concatenated also with | ||
the string ' Hoffman' | ||
""" | ||
return [name + " Hoffman" for name in name_list if name[0] == "K"] | ||
branhoff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
new_name_list: list[str] = [] | ||
for name_in_list in name_list: | ||
if name_in_list[0] == 'K': | ||
new_name_list += [name_in_list + ' Hoffman'] | ||
|
||
return new_name_list | ||
|
||
|
||
# Testing the function | ||
names: list[str] = ["Kiki", "Krystal", "Pavel", "MaryKay", "Annie", "Koala", "Killer"] | ||
changed_name_lists: list[str] = add_surname(names) | ||
name: str | ||
for name in changed_name_lists: | ||
print(name) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.