This is a personal record of my python programming experiences. It will allow me to see how I am progressing as I learn a new language.
Saturday, February 16, 2013
Python Tutorial
I'm taking a tutorial on python. This lesson is showing how to use the sys module. I am enjoying learning new things about python.
Friday, February 1, 2013
Arcmap program
#Written by Steve Atchison Jan 29 2013
def protestacres():
totalacre=0.00
for row in arcpy.SearchCursor("ROW & Protest Acres"):
acres = row.getValue('ClippedAcres')
totalacre=float(totalacre)+float(acres)
print("Area of Protesting Properties = %.2f" % totalacre)
return totalacre
def grossacres(): #1000' Buffer acres
for row in arcpy.SearchCursor("Gross acres including subject & ROW"):
acres = row.getValue('ClippedAcres')
print("Gross acres including Subject Property & ROW = %.2f " %acres)
return acres
def areasubject():
for row in arcpy.SearchCursor("SubjectProperty"):
subjectsqft = row.getValue('Shape_Area')
subjectacres = float(subjectsqft/43560)
print("Area of Subject Property is %.2f " % subjectacres)
return subjectacres
def arearow():
for row in arcpy.SearchCursor("ROW acres"):
rowac = row.getValue('ClippedAcres')
print("Area of Street ROW = %.2f " %rowac)
return rowac
def extent_of_protest():
netacreage = grossacres()-(areasubject()+arearow())
print(protestacres()/float(netacreage))
extent_of_protest()
#SELECT THE PROTESTING PROPERTIES FIRST BEFORE RUNNING THIS PROGRAM!
def protestacres():
totalacre=0.00
for row in arcpy.SearchCursor("ROW & Protest Acres"):
acres = row.getValue('ClippedAcres')
totalacre=float(totalacre)+float(acres)
print("Area of Protesting Properties = %.2f" % totalacre)
return totalacre
def grossacres(): #1000' Buffer acres
for row in arcpy.SearchCursor("Gross acres including subject & ROW"):
acres = row.getValue('ClippedAcres')
print("Gross acres including Subject Property & ROW = %.2f " %acres)
return acres
def areasubject():
for row in arcpy.SearchCursor("SubjectProperty"):
subjectsqft = row.getValue('Shape_Area')
subjectacres = float(subjectsqft/43560)
print("Area of Subject Property is %.2f " % subjectacres)
return subjectacres
def arearow():
for row in arcpy.SearchCursor("ROW acres"):
rowac = row.getValue('ClippedAcres')
print("Area of Street ROW = %.2f " %rowac)
return rowac
def extent_of_protest():
netacreage = grossacres()-(areasubject()+arearow())
print(protestacres()/float(netacreage))
extent_of_protest()
#SELECT THE PROTESTING PROPERTIES FIRST BEFORE RUNNING THIS PROGRAM!
Tuesday, December 25, 2012
#I wrote a simple python program that creates a database with sqlite3 and a GUI with Tkinter. #It won't be useful except as reference for me.
from Tkinter import *
import sqlite3
def makedatabase():
conn=sqlite3.connect('mydb.db')
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS atable(name string, phone string)")
cur.execute("INSERT INTO atable VALUES('Stephany','123-1234')")
thedata=cur.execute("SELECT * FROM atable")
for line in thedata:
print line[0]
print line[1]
root=Tk()
btn=Button(root,text="Run ",command=makedatabase)
btn.pack()
root.mainloop()
from Tkinter import *
import sqlite3
def makedatabase():
conn=sqlite3.connect('mydb.db')
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS atable(name string, phone string)")
cur.execute("INSERT INTO atable VALUES('Stephany','123-1234')")
thedata=cur.execute("SELECT * FROM atable")
for line in thedata:
print line[0]
print line[1]
root=Tk()
btn=Button(root,text="Run ",command=makedatabase)
btn.pack()
root.mainloop()
Saturday, November 17, 2012
PHP, MySql
I have installed MySQL on my netbook. I know python can hook up to MySQL databases. Also, I got PHP installed and I am begining to learn a little about that. I got interested in databases when I started using python to create sqlite3 databases. Now I'm going to try using PHP to manipulate MySql databases.
Tuesday, September 11, 2012
A simple drawing program
#Written by Steve Atchison
from Tkinter import *
from turtle import *
left(90)
def secline():
penup()
fd(2640)
right(90)
fd(2640)
pendown()
pencolor('red')
right(90)
fd(2640)
def turn180deg():
left(180)
def drawline():
linelength =float(length.get())
lineangle=float(angle.get())
right(lineangle)
fd(linelength/10.0)
left(lineangle)
length.delete(0,END)
angle.delete(0,END)
def clearlines():
clear()
root=Tk()
root.title("Line draw")
root.geometry('200x200')
lbl2=Label(root,text='Angle').pack()
angle=Entry(root)
angle.pack()
lbl1 =Label(root,text='Length').pack()
length=Entry(root)
length.pack()
btn1=Button(root,text='Draw',command=drawline)
btn1.pack()
btn2=Button(root,text='Clear',command=clearlines)
btn2.pack()
btn3=Button(root,text='rotate 180',command=turn180deg)
btn3.pack()
root.mainloop()
from Tkinter import *
from turtle import *
left(90)
def secline():
penup()
fd(2640)
right(90)
fd(2640)
pendown()
pencolor('red')
right(90)
fd(2640)
def turn180deg():
left(180)
def drawline():
linelength =float(length.get())
lineangle=float(angle.get())
right(lineangle)
fd(linelength/10.0)
left(lineangle)
length.delete(0,END)
angle.delete(0,END)
def clearlines():
clear()
root=Tk()
root.title("Line draw")
root.geometry('200x200')
lbl2=Label(root,text='Angle').pack()
angle=Entry(root)
angle.pack()
lbl1 =Label(root,text='Length').pack()
length=Entry(root)
length.pack()
btn1=Button(root,text='Draw',command=drawline)
btn1.pack()
btn2=Button(root,text='Clear',command=clearlines)
btn2.pack()
btn3=Button(root,text='rotate 180',command=turn180deg)
btn3.pack()
root.mainloop()
Saturday, September 8, 2012
A simple drawing program
from Tkinter import *
import turtle
root=Tk()
root.title('Steves drawing machine')
can= Canvas(root, width=400,height=300)
can.pack()
def clickhandler(x,y):
t.goto(x,y)
t=turtle.RawTurtle(can)
screen=t.getscreen()
screen.setworldcoordinates(0,0,400,400)
screen.onclick(clickhandler)
root.mainloop()
Subscribe to:
Posts (Atom)
Followers
Blog Archive
- June (1)
- March (3)
- February (1)
- July (3)
- May (1)
- April (1)
- March (1)
- January (1)
- December (1)
- November (4)
- July (3)
- May (2)
- April (1)
- March (6)
- February (2)
- December (1)
- November (1)
- September (3)
- August (3)
- July (1)
- March (3)
- January (1)
- December (5)
- November (2)
- October (1)
- September (2)
- August (1)
- July (4)
- May (3)
- February (1)
- January (1)
- December (1)
- November (2)
- October (2)
- September (9)
- August (2)
- May (1)
- April (1)
- March (6)
- February (5)
- January (3)
- August (2)



