Skip to content

Instantly share code, notes, and snippets.

def geolocation(landmark):
if landmark == "Eiffel":
return 48.858093, 2.294694
elif landmark == "Statue":
return 40.689247, -74.044502
elif landmark == "Opera":
return -33.858611, 151.214167
else:
return 0, 0
def pront(prompt, message):
userinput = input(prompt)
outputmessage = f"{message} {userinput}!"
print(outputmessage)
pront ("Please enter your name: ", "Hello,")
def pront(prompt, message):
print(f"{message} {input(prompt)}!")
pront ("Please enter your name: ", "Hello,")
@raeq
raeq / anagram.py
Created May 14, 2018 11:49
Use list comprehension and prime products to find anagrams.
import sys
from collections import defaultdict
import urllib2
#quit if not python@2
if sys.version_info >= (3, 0):
sys.stdout.write("Sorry, requires Python 2.x, not Python 3.x\n")
sys.exit(1)
@raeq
raeq / quicksort.py
Last active May 14, 2018 14:50
A small python function to quicksort any list from smallest to largest. Now using the correct division operator "//".
def quicksort(p_list):
"""
Quicksort using comprehension and recursion on a list.
"""
if len(p_list) < 1:
return p_list
center = p_list[len(p_list) // 2]