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
7 changes: 7 additions & 0 deletions students/dychowicz_monika/lesson_07/TheNumberOfWords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def main():
text = input()
print(1 + (text.count(' ')))


if __name__ == '__main__':
main()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W292 no newline at end of file

7 changes: 7 additions & 0 deletions students/dychowicz_monika/lesson_07/ToSwapTwoWords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def main():
a, b = [x for x in input().split()]
print(' '.join([b, a]))


if __name__ == '__main__':
main()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W292 no newline at end of file

16 changes: 16 additions & 0 deletions students/dychowicz_monika/lesson_09/Mad_Libs.py
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W292 no newline at end of file

17 changes: 17 additions & 0 deletions students/dychowicz_monika/lesson_09/Regex_Search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os, re
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E401 multiple imports on one line

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix this



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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W292 no newline at end of file

29 changes: 29 additions & 0 deletions students/dychowicz_monika/lesson_09/mcb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! python3
# mcb.pyw - Saves and loads pieces of text to the clipboard.
# Usage: py.exe mcb.pyw save <keyword> - Saves clipboard to keyword.
# py.exe mcb.pyw delete <keyword> - Deletes keyword from clipboard
# py.exe mcb.pyw <keyword> - Loads keyword to clipboard.
# py.exe mcb.pyw list - Loads all keywords to clipboard.

import shelve, pyperclip, sys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E401 multiple imports on one line


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():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E111 indentation is not a multiple of four

del mcbShelf[key]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E111 indentation is not a multiple of four


elif sys.argv[1] in mcbShelf:
pyperclip.copy(mcbShelf[sys.argv[1]])

mcbShelf.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W292 no newline at end of file

29 changes: 29 additions & 0 deletions students/dychowicz_monika/lesson_09/mcb.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! python3
# mcb.pyw - Saves and loads pieces of text to the clipboard.
# Usage: py.exe mcb.pyw save <keyword> - Saves clipboard to keyword.
# py.exe mcb.pyw delete <keyword> - Deletes keyword from clipboard
# py.exe mcb.pyw <keyword> - 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()
3 changes: 3 additions & 0 deletions students/dychowicz_monika/lesson_09/regex_search.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
00-242
test
01-555
1 change: 1 addition & 0 deletions students/dychowicz_monika/lesson_09/replaced.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The funny panda walked to the monkey and then run. A nearby home was unaffected by these events.
1 change: 1 addition & 0 deletions students/dychowicz_monika/lesson_09/to_replace.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN2 was unaffected by these events.