Skip to content

Instantly share code, notes, and snippets.

View Deep18-03's full-sized avatar
🏠
Working from home

Deep18-03

🏠
Working from home
View GitHub Profile
import pprint as p
#pprint is pretty printing module
message = 'hello how are you' count = { }
for character in message:
count.setdefault (character, 0)
count[character] = count[character] + 1
p.pprint (count)
@Deep18-03
Deep18-03 / Birthday info.py
Created March 31, 2020 17:53
Using dictionaries we give bday info about the person
birthday={'dev':'18 mar','deep':'18 mar','yash':'6 may'}
while True:
name=input('enter your name (enter to exit)')
if name=='':
break
if name in birthday:
print(name + ' birthday is at '+ birthday[name])
else:
print('your name is not here ')
bday=input('what is your bday')
@Deep18-03
Deep18-03 / password locker.py
Created April 9, 2020 18:17
Automate borig stuff
passwords={'email':'game','facebook':'dev'}
import sys,pyperclip
if len(sys.argv) < 2:
print("enter proper argument")
sys.exit()
account=sys.argv[1]
if account in passwords:
phonenumber=input('enter your phonenumber')
def isphonenumber(number):
if len(phonenumber) != 10:
return False
for i in range(0,10):
if not number[i].isdecimal():
return False
return True
#check phonenumber using regular expression
import re
phonenumber=input('enter your phonenumber')
def checknumber(number):
phonenum=re.compile(r'\d\d\d\d\d\d\d\d\d\d')
mo=phonenum.search(number)
print('phonenumber found:'+mo.group())
checknumber(phonenumber)
#aeiou character using regular expression
message=input('enter the message')
import re
def vowelslist(message):
vowelRegex=re.compile(r'[aeiouAEIOU]')
print(vowelRegex.findall('hello'))
vowelslist(message)
#consonantlist character using regular expression
message=input('enter the message')
import re
def consonantlist(message):
vowelRegex=re.compile(r'[^aeiouAEIOU]')
print(vowelRegex.findall('hello'))
vowelslist(message)
@Deep18-03
Deep18-03 / os.path.join.py
Created April 10, 2020 11:18
to create filename as string
#os.path.join is used to create the string of filename
import os
myfiles=['account.txt','details.csv','invite.docx']
for filename in myfiles:
print(os.path.join('C:\\Users\\asweigart',filename))
import os
print(os.getcwd())
print(os.chdir('C:\\Windowns')) #chnage working directory
@Deep18-03
Deep18-03 / readfile.py
Created April 19, 2020 06:16
file IO concept
f=open("deep.txt")
#content=f.read() #it will read whole file content
#print(content)
print(f.readline()) #it will read only first line
print(f.readlines()) #it will read file in list