diff --git a/README.md b/README.md index 92644d7..6e51589 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# final-project -final-project python code challenge +# final-project +final-project python code challenge +my forked project diff --git a/StateCap-screen/results-screenshot.png b/StateCap-screen/results-screenshot.png new file mode 100644 index 0000000..58628b2 Binary files /dev/null and b/StateCap-screen/results-screenshot.png differ diff --git a/capital.py b/capital.py new file mode 100644 index 0000000..dbd7ec4 --- /dev/null +++ b/capital.py @@ -0,0 +1,123 @@ +import sys +import json +import pytest + +STATES_CAPITALS = { + 'Alabama': 'Montgomery', + 'Alaska': 'Juneau', + 'Arizona': 'Phoenix', + 'Arkansas': 'Little Rock', + 'California': 'Sacramento', + 'Colorado': 'Denver', + 'Connecticut': 'Hartford', + 'Delaware': 'Dover', + 'Florida': 'Tallahassee', + 'Georgia': 'Atlanta', + 'Hawaii': 'Honolulu', + 'Idaho': 'Boise', + 'Illinois': 'Springfield', + 'Indiana': 'Indianapolis', + 'Iowa': 'Des Moines', + 'Kansas': 'Topeka', + 'Kentucky': 'Frankfort', + 'Louisiana': 'Baton Rouge', + 'Maine': 'Augusta', + 'Maryland': 'Annapolis', + 'Massachusetts': 'Boston', + 'Michigan': 'Lansing', + 'Minnesota': 'Saint Paul', + 'Mississippi': 'Jackson', + 'Missouri': 'Jefferson City', + 'Montana': 'Helena', + 'Nebraska': 'Lincoln', + 'Nevada': 'Carson City', + 'New Hampshire': 'Concord', + 'New Jersey': 'Trenton', + 'New Mexico': 'Santa Fe', + 'New York': 'Albany', + 'North Carolina': 'Raleigh', + 'North Dakota': 'Bismarck', + 'Ohio': 'Columbus', + 'Oklahoma': 'Oklahoma City', + 'Oregon': 'Salem', + 'Pennsylvania': 'Harrisburg', + 'Rhode Island': 'Providence', + 'South Carolina': 'Columbia', + 'South Dakota': 'Pierre', + 'Tennessee': 'Nashville', + 'Texas': 'Austin', + 'Utah': 'Salt Lake City', + 'Vermont': 'Montpelier', + 'Virginia': 'Richmond', + 'Washington': 'Olympia', + 'West Virginia': 'Charleston', + 'Wisconsin': 'Madison', + 'Wyoming': 'Cheyenne', +} + + +# CAPITALS_STATES = {capital:state for state, capital in STATES_CAPITALS.items()} +def capital_of_Idaho(): + return STATES_CAPITALS['Idaho'] + + +def all_states(): + return STATES_CAPITALS.keys() + + +def all_capitals(): + return STATES_CAPITALS.values() + + +def states_capitals_string(): + return ' , '.join([f'{state} - > {capital}' for state, capital in STATES_CAPITALS.items()]) + + +def get_state(): + sorted_states = sorted(STATES_CAPITALS.items()) + return ' , '.join([f'{state} - > {capital}' for (state, capital) in sorted_states]) + + +def get_state_7(): + return {capital: state for state, capital in STATES_CAPITALS.items()} + + +# def get_state_8(capital): +# return CAPITALS_STATES.get(capital, "None") + +# new_dict = {} +# for state, capital in STATES_CAPITALS.items(): +# new_dict[capital] = state +# def test_state_to_capital(): +# assert 'Cheyenne' == STATES_CAPITALS['Wyoming'] + + +print("1)", capital_of_Idaho()) +print("2)", all_states()) +print("3)", all_capitals()) +print("4)", states_capitals_string()) +print("5)", get_state()) +print("7)", get_state_7()) +# a= get_state_8('Lansing') +# print (a) + + +## with pytest.raises(KeyError): +# STATES_CAPITALS[''] + + +# def test_capital_to_state(): +# assert 'Wyoming' == get_state('Cheyenne') + + +# def test_capital_to_state_unknown(): +# with pytest.raises(KeyError): +# get_state('') + + +# def main(): +# return pytest.main(__file__) + + +# if __name__ == '__main__': +# sys.exit(main()) diff --git a/string-screen/string-screenshot.png b/string-screen/string-screenshot.png new file mode 100644 index 0000000..cc2565d Binary files /dev/null and b/string-screen/string-screenshot.png differ diff --git a/strings.py b/strings.py index 7915338..bc8db25 100644 --- a/strings.py +++ b/strings.py @@ -1,47 +1,71 @@ -"""With this string: -'monty pythons flying circus' -Create a function that returns a sorted string with no duplicate characters -(keep any whitespace): -Example: ' cfghilmnoprstuy' -Create a function that returns the words in reverse order: -Example: ['circus', 'flying', 'pythons', 'monty'] -Create a function that returns a list of 4 character strings: -Example: ['mont', 'y py', 'thon', 's fl', 'ying', ' cir', 'cus'] -### git comment -""" -import pytest - -def no_duplicates(a_string): - pass - - -def reversed_words(a_string): - pass - - -def four_char_strings(a_string): - pass - - -def test_no_duplicates(): - s = 'monty pythons flying circus' - assert no_duplicates(s) == ' cfghilmnoprstuy' - - -def test_reversed_words(): - s = 'monty pythons flying circus' - assert reversed_words(s) == ['circus', 'flying', 'pythons', 'monty'] - - -def test_four_char_strings(): - s = 'monty pythons flying circus' - assert four_char_strings(s) == ['mont', 'y py', 'thon', 's fl', 'ying', ' cir', 'cus'] - - -def main(): - return pytest.main(__file__) - - -if __name__ == '__main__': - main() - +"""With this string: +'monty pythons flying circus' +Create a function that returns a sorted string with no duplicate characters +(keep any whitespace): +Example: ' cfghilmnoprstuy' +Create a function that returns the words in reverse order: +Example: ['circus', 'flying', 'pythons', 'monty'] +Create a function that returns a list of 4 character strings: +Example: ['mont', 'y py', 'thon', 's fl', 'ying', ' cir', 'cus'] +### git comment +""" +import chunk + +import pytest + + +def no_duplicates(a_string): + return list(dict.fromkeys(a_string)) +mylist = no_duplicates ("monty""pythons""flying""circus") +print("1)",mylist) + + +def reversed_words(a_string): + words = a_string.split(' ') + reverse_a_string = ' '.join(reversed(words)) + return reverse_a_string + + +if __name__ == "__main__": + list = 'monty pythons flying circus' + print("2)",reversed_words(list)) + + +def four_char_strings(a_string, chunk): + lst = [] + if chunk <= len(a_string): + lst.extend([a_string[:chunk]]) + lst.extend(four_char_strings(a_string[chunk:], chunk,)) + return lst + + +a_string = "monty pythons flying circus" +print("3)",four_char_strings(a_string, 4)) + +# + + + + # +# +# def test_no_duplicates(): +# s = 'monty pythons flying circus' +# assert no_duplicates(s) == ' cfghilmnoprstuy' +# +# +# def test_reversed_words(): +# s = 'monty pythons flying circus' +# assert reversed_words(s) == ['circus', 'flying', 'pythons', 'monty'] +# +# +# def test_four_char_strings(): +# s = 'monty pythons flying circus' +# assert four_char_strings(s) == ['mont', 'y py', 'thon', 's fl', 'ying', ' cir', 'cus'] +# +# +# def main(): +# return pytest.main(__file__) + + +# if __name__ == '__main__': +# main()