Skip to content

Instantly share code, notes, and snippets.

gwith@Gwith-PC:~$ python3
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyperclip
>>> pyperclip.copy('Hello world!')
>>> pyperclip.paste()
'Hello world!'
[2]+ Stopped python2
gwith@Gwith-PC:~$ python
gwith@Gwith-PC:~/Documents$ python test.py
gwith@Gwith-PC:~/Documents$
gwith@Gwith-PC:~/Documents$ python test.py
gwith@Gwith-PC:~/Documents$
test1 = { 'cat' : 1, 'dog' : 1, 'bird' : 1}
test2 = { 'cat' : 3, 'dog' : 2, 'cow' : 2 }
for key in test2:
test1[key] = test1.get(key, 0) + test2[key]
print(test1)
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
def printTable(tableData):
colWidths = [0] * len(tableData)
for i in tableData:
for j in i:
import netmiko
#.hp import HPProcurveSSH, HPComwareSSH
hp_procurve = {
'device_type': 'hp_procurve',
'ip': '192.168.x.x',
'username': 'test',
'password': '1234',
'port': 22
tableData=[['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
newTable = { 0:[], 1:[], 2:[], 3:[] }
for list in tableData:
for element in range(len(list)):
newTable[element].append(list[element])
# Calculate when user will be 100 years old
import datetime #import datetime to grab year.
def age():
name = input("What is your name?\n") #grab input of user 'name'
name = name.replace(name[0], name[0].upper()) #replace first letter with capitol
try:
age = int(input("What is your age?\n")) #grab user age and change to int
# Calculate when user will be 100 years old
import datetime #import datetime to grab year.
name = input("What is your name?\n") #grab input of user 'name'
name = name.replace(name[0], name[0].upper()) #replace first letter with capitol
age = 0
try:
age = int(input("What is your age?\n")) #grab user age and change to int
# Calculate when user will be 100 years old
import datetime #import datetime to grab year.
name = input("What is your name?\n") #grab input of user 'name'
name = name.replace(name[0], name[0].upper()) #replace first letter with capitol
age = 0
while True: