Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/final-project.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

163 changes: 89 additions & 74 deletions StateCap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""We have an existing dictionary that maps US states to their capitals.
"""
1. Print the state capital of Idaho
2. Print all states.
3. Print all capitals.
Expand All @@ -16,103 +16,118 @@
import pytest

STATES_CAPITALS = {
'Alabama' : 'Montgomery',
'Alaska' : 'Juneau',
'Arizona' : 'Phoenix',
'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',
'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',
}


def capital_of_Idaho():
# Your code here
pass
def capital_of_idaho():
print(STATES_CAPITALS.get('Idaho'))
capital_of_idaho()
#pass




def all_states():
# Your code here
pass
for key in STATES_CAPITALS.keys():
print(key)
all_states()
#pass


def all_capitals():
# Your code here
pass
for value in STATES_CAPITALS.values():
print(value)
all_capitals()
#pass

def states_capitals_string():
# Your code here
pass
for key, value in sorted(STATES_CAPITALS.items()):
print("{key} -> {value}".format(key=key, value=value))
#pass
states_capitals_string()



def get_state(capital):
pass
for key, value in STATES_CAPITALS.items():
if capital==value:
print(key)
get_state('Salem')
#pass



def test_state_to_capital():
assert 'Cheyenne' == STATES_CAPITALS['Wyoming']
#def test_state_to_capital():
#assert 'Cheyenne' == STATES_CAPITALS['Wyoming']


def test_state_to_capital_unknown():
with pytest.raises(KeyError):
STATES_CAPITALS['']
#def test_state_to_capital_unknown():
#with pytest.raises(KeyError):
#STATES_CAPITALS['']


def test_capital_to_state():
assert 'Wyoming' == get_state('Cheyenne')
#def test_capital_to_state():
#assert 'Wyoming' == get_state('Cheyenne')


def test_capital_to_state_unknown():
with pytest.raises(KeyError):
get_state('')
#def test_capital_to_state_unknown():
#with pytest.raises(KeyError):
#get_state('')


def main():
return pytest.main(__file__)
#def main():
#return pytest.main(__file__)


if __name__ == '__main__':
sys.exit(main())
#if __name__ == '__main__':
#sys.exit(main())
57 changes: 37 additions & 20 deletions strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,54 @@
"""
import pytest

def no_duplicates(a_string):
pass
def no_duplicates():
x = ('monty pythons flying circus')
a = ''.join(sorted(set(x)))
print(a)
no_duplicates()

#pass

def reversed_words(a_string):
pass

def reversed_words():
x = ['circus', 'flying', 'pythons', 'monty']
a = x[4::-1]
print(a)
reversed_words()
#pass

def four_char_strings(a_string):
pass

def four_char_strings(s):
return [s[i: i + 4] for i in range(0, len(s), 4)]
x = four_char_strings('monty pythons flying circus')
print(x)

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

#pass

def main():
return pytest.main(__file__)

#def test_no_duplicates():
#s = 'monty pythons flying circus'
#assert no_duplicates(s) == ' cfghilmnoprstuy'

if __name__ == '__main__':
main()


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