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
68 changes: 25 additions & 43 deletions StateCap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
handle that?

"""
import sys

import pytest
import sys

STATES_CAPITALS = {
'Alabama' : 'Montgomery',
Expand Down Expand Up @@ -68,51 +67,34 @@
'Wyoming' : 'Cheyenne',
}


def capital_of_Idaho():
# Your code here
pass
def capital_Idaho():
print(STATES_CAPITALS['Idaho'])
capital_Idaho()
pass

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

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

def states_capitals_string():
# Your code here
pass



def get_state(capital):
pass



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


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_unknown():
with pytest.raises(KeyError):
get_state('')


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

lst = STATES_CAPITALS.keys()
sort = sorted(lst)
print(sort)
states_capitals_string()
pass

def get_state():
stat = input('Provide Capital:')
for st, cap in STATES_CAPITALS.items():
if cap.lower() == stat:
results = st+ " " +cap
print(results)
get_state()
pass

if __name__ == '__main__':
sys.exit(main())
3 changes: 3 additions & 0 deletions new1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-World
hEllo-World
vhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-World1323213131321334543543543543543534543
61 changes: 26 additions & 35 deletions strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,30 @@
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()

def no_duplicates():
str = 'monty pythons flying circus'
remove = ''.join(sorted(set(str), key=str.index))
sort = ''.join(sorted(remove))
print(sort)
no_duplicates()
pass

def reversed_words(sentence):
# first split the string into words
words = sentence.split(' ')
# then reverse the split string list and join using space
reverse_sentence = ' '.join(reversed(words))
# finally return the joined string
return reverse_sentence
if __name__ == "__main__":
input = 'monty pythons flying circus'
print(reversed_words(input))
pass

def four_char_strings():
str1 = ['monty', 'pythons', 'flying', 'circus']
for i in str1:
print(i[:4])
four_char_strings()
pass
4 changes: 4 additions & 0 deletions test8766
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
new
new
new