Skip to content

Commit 0c64d85

Browse files
authored
Add files via upload
1 parent 64cc025 commit 0c64d85

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

PhoneNumber.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def isPhoneNumber(text):
2+
if len(text) != 12:
3+
return False
4+
for i in range(0, 3):
5+
if not text[i].isdecimal():
6+
return False
7+
if text[3] != '-':
8+
return False
9+
for i in range(4, 7):
10+
if not text[i].isdecimal():
11+
return False
12+
if text[7] != '-':
13+
return False
14+
for i in range(8, 12):
15+
if not text[i].isdecimal():
16+
return False
17+
return True
18+
19+
20+
message = 'Call me at 415-555-1011 tomorrow. 415-555-9999 is my office.'
21+
for i in range(len(message)):
22+
chunk = message[i:i+12]
23+
if isPhoneNumber(chunk):
24+
print('Phone number found: ' + chunk)
25+
print('Done')

bulletPointAdder.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#! python3
2+
# bulletPointAdder.py - Adds Wikipedia bullet points to the start
3+
# of each line of text on the clipboard.
4+
5+
6+
import pyperclip
7+
text = pyperclip.paste()
8+
9+
10+
# Seperate lines and add stars.
11+
lines = text.split('\n')
12+
for i in range(len(lines)): # loop through all indexes in the "lines" list
13+
lines[i] = '* ' + lines[i] # add star to each string in "lines" list
14+
15+
16+
text = '\n'.join(lines)
17+
pyperclip.copy(text)

picnicTable.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def printPicnic(itemsDict, leftWitdh, rightWidth):
2+
print('PICNIC ITEMS'.center(leftWitdh + rightWidth, '-'))
3+
for k, v in itemsDict.items():
4+
print(k.ljust(leftWitdh, '-') + str(v).rjust(rightWidth))
5+
picnicItems = {'sandwiches': 4, 'apples': 12, 'cups': 4, 'cookies': 8000}
6+
printPicnic(picnicItems, 12, 5)
7+
printPicnic(picnicItems, 20, 6)

pw.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! python3
2+
#pw.py - An insecure password locker program.
3+
4+
PASSWORDS = {'email':'F7minlBDDuvMJuxESSKHFhTxFtjVB6',
5+
'blog':'VmALvQyKAxiVH5G8v01if1MLZF3sdt',
6+
'luggage': '12345'}
7+
8+
import sys
9+
if len(sys.argv) < 2:
10+
print('Usage: python pw.py [account] - copy account password')
11+
sys.exit()
12+
13+
14+
account = sys.argv[1] #first command line arg is the account time
15+
16+
17+
if account in PASSWORDS:
18+
pyperclip.copy(PASSWORDS[account])
19+
print('Password for ' + account + ' copied to clipboard.')
20+
else:
21+
print('There is no account named ' + account)

regex.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import re
2+
phoneNumRegex = re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)')
3+
mo = phoneNumRegex.search('My number is 415-555-4242.')
4+
mo.group(1)

validateInput.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
while True:
2+
print('Enter your age:')
3+
age = input()
4+
if age.isdecimal():
5+
break
6+
print('Please enter a number for your age.')
7+
8+
while True:
9+
print('Select a new password (letters and numbers only):')
10+
password = input()
11+
if password.isalnum():
12+
break
13+
print('Passwords can only have letters and numbers.')
14+

0 commit comments

Comments
 (0)