diff --git a/students/dychowicz_monika/lesson_07/TheNumberOfWords.py b/students/dychowicz_monika/lesson_07/TheNumberOfWords.py new file mode 100644 index 000000000..ccdbc648b --- /dev/null +++ b/students/dychowicz_monika/lesson_07/TheNumberOfWords.py @@ -0,0 +1,7 @@ +def main(): + text = input() + print(1 + (text.count(' '))) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_07/ToSwapTwoWords.py b/students/dychowicz_monika/lesson_07/ToSwapTwoWords.py new file mode 100644 index 000000000..5ba82ad34 --- /dev/null +++ b/students/dychowicz_monika/lesson_07/ToSwapTwoWords.py @@ -0,0 +1,7 @@ +def main(): + a, b = [x for x in input().split()] + print(' '.join([b, a])) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/Mad_Libs.py b/students/dychowicz_monika/lesson_09/Mad_Libs.py new file mode 100644 index 000000000..af8a7306b --- /dev/null +++ b/students/dychowicz_monika/lesson_09/Mad_Libs.py @@ -0,0 +1,16 @@ +words_to_find = ['ADJECTIVE', 'NOUN', 'VERB', 'NOUN2'] + +filename = input("Enter a filename: ") +text_file = open(filename, "r") +content = text_file.read() +text_file.close() + +for word in words_to_find: + content = content.replace(word, input("Enter an " + word.lower() + ': '), + 1) +write_filename = input("Enter a filename for writing the data: ") +write_filename = open(write_filename, 'w') +write_filename.write(content) +write_filename.close() + +print(content) \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/Regex_Search.py b/students/dychowicz_monika/lesson_09/Regex_Search.py new file mode 100644 index 000000000..aa69fa846 --- /dev/null +++ b/students/dychowicz_monika/lesson_09/Regex_Search.py @@ -0,0 +1,17 @@ +import os, re + + +def regex_search(reg): + regex = re.compile(reg) + files_list = os.listdir('.') + + for file in files_list: + if file.endswith('.txt'): + with open(file) as textfile: + for line in textfile: + if regex.match(line): + print("Regex found " + line) + + +regex = input("Enter a regex: ") +regex_search(regex) \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/mcb.py b/students/dychowicz_monika/lesson_09/mcb.py new file mode 100644 index 000000000..da85f9af5 --- /dev/null +++ b/students/dychowicz_monika/lesson_09/mcb.py @@ -0,0 +1,29 @@ +#! python3 +# mcb.pyw - Saves and loads pieces of text to the clipboard. +# Usage: py.exe mcb.pyw save - Saves clipboard to keyword. +# py.exe mcb.pyw delete - Deletes keyword from clipboard +# py.exe mcb.pyw - Loads keyword to clipboard. +# py.exe mcb.pyw list - Loads all keywords to clipboard. + +import shelve, pyperclip, sys + +mcbShelf = shelve.open('mcb') + + +# save clipboard content. +if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': + mcbShelf[sys.argv[2]] = pyperclip.paste() +elif len(sys.argv) == 3 and sys.argv[1].lower() == 'delete': + del mcbShelf[sys.argv[2]] +elif len(sys.argv) == 2: + # list keywords and load content. + if sys.argv[1].lower() == 'list': + pyperclip.copy(str(list(mcbShelf.keys()))) + if sys.argv[1].lower() == 'delete': + for key in mcbShelf.keys(): + del mcbShelf[key] + + elif sys.argv[1] in mcbShelf: + pyperclip.copy(mcbShelf[sys.argv[1]]) + +mcbShelf.close() \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/mcb.pyw b/students/dychowicz_monika/lesson_09/mcb.pyw new file mode 100644 index 000000000..da85f9af5 --- /dev/null +++ b/students/dychowicz_monika/lesson_09/mcb.pyw @@ -0,0 +1,29 @@ +#! python3 +# mcb.pyw - Saves and loads pieces of text to the clipboard. +# Usage: py.exe mcb.pyw save - Saves clipboard to keyword. +# py.exe mcb.pyw delete - Deletes keyword from clipboard +# py.exe mcb.pyw - Loads keyword to clipboard. +# py.exe mcb.pyw list - Loads all keywords to clipboard. + +import shelve, pyperclip, sys + +mcbShelf = shelve.open('mcb') + + +# save clipboard content. +if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': + mcbShelf[sys.argv[2]] = pyperclip.paste() +elif len(sys.argv) == 3 and sys.argv[1].lower() == 'delete': + del mcbShelf[sys.argv[2]] +elif len(sys.argv) == 2: + # list keywords and load content. + if sys.argv[1].lower() == 'list': + pyperclip.copy(str(list(mcbShelf.keys()))) + if sys.argv[1].lower() == 'delete': + for key in mcbShelf.keys(): + del mcbShelf[key] + + elif sys.argv[1] in mcbShelf: + pyperclip.copy(mcbShelf[sys.argv[1]]) + +mcbShelf.close() \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/regex_search.txt b/students/dychowicz_monika/lesson_09/regex_search.txt new file mode 100644 index 000000000..9b41acad9 --- /dev/null +++ b/students/dychowicz_monika/lesson_09/regex_search.txt @@ -0,0 +1,3 @@ +00-242 +test +01-555 \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/replaced.txt b/students/dychowicz_monika/lesson_09/replaced.txt new file mode 100644 index 000000000..0aeb939d8 --- /dev/null +++ b/students/dychowicz_monika/lesson_09/replaced.txt @@ -0,0 +1 @@ +The funny panda walked to the monkey and then run. A nearby home was unaffected by these events. \ No newline at end of file diff --git a/students/dychowicz_monika/lesson_09/to_replace.txt b/students/dychowicz_monika/lesson_09/to_replace.txt new file mode 100644 index 000000000..f967e7531 --- /dev/null +++ b/students/dychowicz_monika/lesson_09/to_replace.txt @@ -0,0 +1 @@ +The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN2 was unaffected by these events. \ No newline at end of file