snippsat 661 Master Poster
IDLE 2.6.2      
>>> start = 14
>>> end = 2
>>> if start <= 21 and end <= 21: # if start before and end before 9pm.
	payment =(end - start)*5

	
>>> print "The payment is: ",payment, "dollars"
The payment is:  -60 dollars
>>> if start <= 21 and end <= 21: # if start before and end before 9pm.
	payment =(start - end)*5

	
>>> print "The payment is: ",payment, "dollars"
The payment is:  60 dollars
>>>
snippsat 661 Master Poster

There's an error in your program:
***'return' outside function (line 129)

You can not use return outside a function.

IDLE 2.6.2      
>>> def a(x, y):
	return x + y

>>> a(5, 8)
13
>>> x = 5
>>> y = 8
>>> return x + y #this you can not do because outside a function
SyntaxError: 'return' outside function
>>>

If you gone make change a code like this you have to understad the basic of python.
Make small changes and test it out.
Return outside a function will always give a error.

snippsat 661 Master Poster
snippsat 661 Master Poster
>>> start = 1
>>> end = 19

>>> while start < end:
	print start

#What happens here,try to think about it.
#Yes it print 1 forever,ctrl + c to break out when in IDLE.
#Because 1 is less than 19 and we do not multiply start(1)

###
>>> while start < end:
	print start
	start = start + 1  #or start += 1

#What happens here,try to think about it.
#yes we add 1 + 1, 1 + 2, 1 + 3 til we reach end(19)
#If no end(19) while loop will go on forever(Infinite Loop)

#paulthom12345 has the last part you need to figure this out.
snippsat 661 Master Poster

You should try to put some code together.

Look at this,and you should figure how to set opp your variables.

IDLE 2.6.2 
>>> for i in range(1, 20, 3):
	print i   #print (i) for python 3	
1
4
7
10
13
16
19
######
#User input for python 2.x
>>> Start = int(raw_input('Enter first number: '))
Enter first number: 1
>>> Start
1
>>> type(Start)
<type 'int'>
>>> 
######
#User input for python 3.x
>>> Start = int(input('Enter first number: '))
Enter first number: 1
>>> Start
1
>>> type(Start)
<class 'int'>
>>>
snippsat 661 Master Poster
NW, SE, NE, SW = 0, 0, 0, 0
def checkLights( buttonNum ):
      global NW, SE, NE, SW
      if buttonNum == "button 1":

The use of global is`s not a god thing at all.
Try to avoid at all cost.
This do the same.

def checkLights( buttonNum ):
    NW, SE, NE, SW = 0, 0, 0, 0      
    if buttonNum == "button 1":
snippsat 661 Master Poster

One short way for second code.

>>> s = raw_input("Enter a string: ")
Enter a string: car
>>> print 'The reverse is %s' % (s[::-1])
The reverse is rac
snippsat 661 Master Poster
IDLE 2.6.2      
>>> first = [ "robert", "jim", "jack" ]
>>> last = [ "smith", "white", "black" ]
>>> peeps = [ first, last ]
>>> peeps
[['robert', 'jim', 'jack'], ['smith', 'white', 'black']]
>>> prefix = ['mr', 'ms', 'mrs', 'sir']
>>> peeps.append(prefix)
>>> peeps
[['robert', 'jim', 'jack'], ['smith', 'white', 'black'], ['mr', 'ms', 'mrs', 'sir']]
>>> #append put list last

>>> peeps = [ first, last ]
>>> peeps
[['robert', 'jim', 'jack'], ['smith', 'white', 'black']]
>>> peeps.insert(1, prefix)
>>> peeps
[['robert', 'jim', 'jack'], ['mr', 'ms', 'mrs', 'sir'], ['smith', 'white', 'black']]
>>> #insert(i, list)here can you control placement

>>> #so now you can remove the insert list at placement 1
>>> peeps.pop(1)
['mr', 'ms', 'mrs', 'sir']
>>> peeps
[['robert', 'jim', 'jack'], ['smith', 'white', 'black']]
snippsat 661 Master Poster

This is one way.

import os

def on_button(event):
'''event handling on push button open notepad'''
os.startfile('notepad') #or path to your exe
snippsat 661 Master Poster

This is just on the fly, but I tested it and it works.

Yes it work ,but this part It`s making ting a little harder and dont make much sense

for i in range(len(lucky)):
    if lucky[i] == "7":

.

>>> lucky = raw_input("Please enter an integer: ")
Please enter an integer: 7
>>> lucky
'7'
>>> #now why should we use and string in a range for loop.
>>> #dos len make it better
>>> len(lucky)
1
>>> #no
>>> for i in range(1):
	i
	
0
>>> #this line is much clearer
>>> if '7' in lucky:
>>> #dos the same as this lines
>>> for i in range(len(lucky)):
    if lucky[i] == "7":
        is_lucky = True
>>>

So if we put suggestion in this poste together with a loop an exception handling.
It would look somthing like this.

while True:   
    try:
        lucky = raw_input("Enter an integer: ")
        int(lucky.strip())
        if '7' in lucky:
            print '%s is lucky!' % (lucky)
            #break #if you want out of the loop
        else:
            print '%s is not so lucky' % (lucky)
    except ValueError:
        print 'Please number only'
snippsat 661 Master Poster

Forget i made change to this 2 lines to.

scale = tk.Scale(root, label="Select a distance traveled.",
    from_=1, to=1500, tickinterval=0, resolution=1, length=600,
    showvalue='yes', orient='horizontal',command=on_move)

label = tk.Label(root, text='---', bg='green')
snippsat 661 Master Poster

You need event handling.
Put this function at top after import like this.

import tkinter as tk

def on_move(value=0):
    f = scale.get()    
    label['text'] = f

Now you see that your down slider is working.
So now just figure out the calulate stuff,and you have a nice program.

snippsat 661 Master Poster

I get error "TypeError: a float is required." if I simply try "math.sqrt(n). However I think its a similar issue as the last problem I had.

>>> import math
>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'hypot', 'isinf', 'isnan', 'ldexp', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
>>> #Some useful stuff
>>> print (math.sqrt.__doc__)
sqrt(x)

Return the square root of x.
>>> help(math.sqrt)
Help on built-in function sqrt in module math:

sqrt(...)
    sqrt(x)
    
    Return the square root of x.

>>> #So test it out
>>> n = 9
>>> math.sqrt(n)
3.0
>>> #will it work with float number?
>>> n = 9.5
>>> type(n)
<class 'float'>
>>> math.sqrt(n)
3.082207001484488
>>> #So let make a TypeError
>>> n = [1,2,3]
>>> math.sqrt(n)
Traceback (most recent call last):
  File "<pyshell#110>", line 1, in <module>
    math.sqrt(n)
TypeError: a float is required
>>> #So math.sqrt can take integer/float but not list
>>>
snippsat 661 Master Poster

Please test your functions.

>>> def dOdd(n):
    # Returns True if odd
    for n in range(first, last):
        if n % 2 == 1:
            return True
        else:
            return False
        
>>> dOdd(5)
False
>>> dOdd(6)
False
>>> dOdd(2)
False
>>> dOdd(9)
False
>>> 
#So it not so hard to se that it dont work.
>>> n = [2,3,4,5]
>>> odd = 5
>>> def linePrinting(n, odd):
    length = len(n)
    if odd == True:
        odd = "odd"
    else:
        odd = "even"
    for x in range(1, length):
        print (n[x]), odd

        
>>> linePrinting(n, odd)
3
4
5
>>> #so think off does this do what you want?

I am not sure what you want now.
Explain very clear what you want,so it is eaiser to help.

snippsat 661 Master Poster

So you have first and last user inupt value that you use range on.
Then you have a list with number.

>>> first = 2
>>> last = 9
x = list(range(first, last)) 
[2, 3, 4, 5, 6, 7, 8]

>>># now to find odd/even you can use this
>>> x[::2]
[2, 4, 6, 8]
>>> x[1::2]
[3, 5, 7]
>>>

Or look at this solution make 2 list odd/even based on range given by user.

n_odd = []
n_even = []

first = int(input("Enter a starting integer: "))  #input 2
last = int(input("Enter an ending integer: "))    #input 8

for integer in range(first, last):
    if integer % 2 == 1:
        n_odd.append(integer)
    else:
        n_even.append(integer)

print(n_odd)
print(n_even)

'''my output-->
[3, 5, 7]
[2, 4, 6]
'''
snippsat 661 Master Poster

So lets think about what you are doing.

first = int(input("Enter a starting integer: ")) # we make it return a integer
first = first - 1
last = int(input("Enter an ending integer: "))   # we make it return a integer
last = last + 1

print (first) # test print
print (last) # test print

#so now this part work

linePrinting()  # this must have 2 argumet and you have given it 0

n = []
for integer in range(first,last):
    n.append(integer)    # here you making a list
    if dOdd(a) == True:  # you dont have a anywere
        odd = "even"
    else:
        odd = "odd"

# and you cant compare a list for opp/even
# back to idle
>>> def dOdd(n):
    # Returns True if odd
    if (n % 2) == 1:
        return True
    else:
        return False

>>> dOdd(5)
True
>>> dOdd(6)
False
>>> x = [2,3,4,5,6]
>>> dOdd(x)  #try to compare list for even/odd
Traceback (most recent call last):
  File "<pyshell#65>", line 1, in <module>
    dOdd(x)
  File "<pyshell#61>", line 3, in dOdd
    if (n % 2) == 1:
TypeError: unsupported operand type(s) for %: 'list' and 'int' #this can not take a list

So rethink what you are trying to do.

snippsat 661 Master Poster

So i used python 2.x.
Rember () for print in python3.x print('odd')

Now from idle python 3.x

>>> #Let look at type
>>> first = input("Enter a starting integer: ")
Enter a starting integer: 8
>>> 8
8
>>> type(first)
<class 'str'>
>>> #you se this is a string
>>> #so if you gone compare it to integer convert it
>>> a = int(first)
>>> a
8
>>> type(a)
<class 'int'>
>>> #now it`s a integer
>>> def odd(number):
	if number % 2 == 1:
		print ('odd')
	else:
		print ('even')

		
>>> odd(a)
even
>>>

TypeError: unsupported operand type(s) for %: 'list' and 'int'

So now you know how to check for type.
If not correct type you get a message like you got TypeError.

snippsat 661 Master Poster

For determining whether the number is odd or even I have this:

Just som traning in idle is good to do.

>>> 2 % 2
0
>>> 3 % 2
1
>>> 4 % 2
0
>>> 5 % 2
1
>>> 6 % 2
0
>>> # now you see not so hard
>>> 
>>> # we make a function that print odd/even
>>> def odd(number):
	if number % 2 == 1:
		print 'odd'
	else:
		print 'even'
		
>>> odd(2)
even
>>> odd(3)
odd
>>> #we make a function that return True/false
>>> def odd(number):
	if number % 2 == 1:
		return True
	return False

>>> odd(6)
False
>>> odd(7)
True
>>>
snippsat 661 Master Poster

You can try this changes.

import wx

window=wx.App()

class s_report(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self,None,-1,"Grade It!",size=(500,700))

        self.panel=wx.Panel(self,-1)

        menu=wx.MenuBar()

        file_menu=wx.Menu()
        file_menu.Append(301,"Quit")
        self.Bind(wx.EVT_MENU,self.Quit,id=301)

        help_menu=wx.Menu()
        help_menu.Append(302,"About")
        self.Bind(wx.EVT_MENU,self.about,id=302)

        menu.Append(file_menu,"File")
        menu.Append(help_menu,"Help")

        self.SetMenuBar(menu)

        wx.StaticText(self.panel,-1,"Welcome to Grade It!.\nPlease enter your exam marks for 12 subjects. Your highest\nscoring and lowest scoring subject, along with your percentage and grade will be displayed.",pos=(10,10))
        wx.StaticText(self.panel,-1,"Please enter the marks of 12 subjects:",pos=(10,70))

        wx.StaticText(self.panel,-1,"English Language:",pos=(10,100))
        wx.StaticText(self.panel,-1,"English Literature:",pos=(10,125))
        wx.StaticText(self.panel,-1,"Mathematics:",pos=(10,150))
        wx.StaticText(self.panel,-1,"Language II",pos=(10,175))
        wx.StaticText(self.panel,-1,"Physics:",pos=(10,200))
        wx.StaticText(self.panel,-1,"Chemistry:",pos=(10,225))
        wx.StaticText(self.panel,-1,"Biology:",pos=(10,250))
        wx.StaticText(self.panel,-1,"History/Civics:",pos=(10,275))
        wx.StaticText(self.panel,-1,"Geography:",pos=(10,300))
        wx.StaticText(self.panel,-1,"Environmental Education",pos=(10,325))
        wx.StaticText(self.panel,-1,"Computer Science",pos=(10,350))
        wx.StaticText(self.panel,-1,"Computer Practicals",pos=(10,375))

        self.one=wx.TextCtrl(self.panel,-1,'0',pos=(150,100),size=(40,20))
        self.two=wx.TextCtrl(self.panel,-1,'0',pos=(150,125),size=(40,20))
        self.three=wx.TextCtrl(self.panel,-1,'0',pos=(150,150),size=(40,20))
        self.four=wx.TextCtrl(self.panel,-1,'0',pos=(150,175),size=(40,20))
        self.five=wx.TextCtrl(self.panel,-1,'0',pos=(150,200),size=(40,20))
        self.six=wx.TextCtrl(self.panel,-1,'0',pos=(150,225),size=(40,20))
        self.seven=wx.TextCtrl(self.panel,-1,'0',pos=(150,250),size=(40,20))
        self.eight=wx.TextCtrl(self.panel,-1,'0',pos=(150,275),size=(40,20))
        self.nine=wx.TextCtrl(self.panel,-1,'0',pos=(150,300),size=(40,20))
        self.ten=wx.TextCtrl(self.panel,-1,'0',pos=(150,325),size=(40,20))
        self.eleven=wx.TextCtrl(self.panel,-1,'0',pos=(150,350),size=(40,20))
        self.twelve=wx.TextCtrl(self.panel,-1,'0',pos=(150,375),size=(40,20))

        wx.Button(self.panel,201,"Done",pos=(130,400))
        self.Bind(wx.EVT_BUTTON,self.Done,id=201)

        self.Centre()
        self.Show()

    def Done(self,event):        
        
        self.marks = []        
        try:           
            self.marks.append(int(self.one.GetValue()))
            self.marks.append(int(self.two.GetValue()))
            self.marks.append(int(self.three.GetValue()))
            self.marks.append(int(self.four.GetValue()))
            self.marks.append(int(self.five.GetValue()))
            self.marks.append(int(self.six.GetValue()))
            self.marks.append(int(self.seven.GetValue()))
            self.marks.append(int(self.eight.GetValue()))
            self.marks.append(int(self.nine.GetValue()))
            self.marks.append(int(self.ten.GetValue()))
            self.marks.append(int(self.eleven.GetValue()))
            self.marks.append(int(self.twelve.GetValue()))
        except:
            self.marks.append(float(self.one.GetValue()))
            self.marks.append(float(self.two.GetValue()))
            self.marks.append(float(self.three.GetValue()))
            self.marks.append(float(self.four.GetValue()))
            self.marks.append(float(self.five.GetValue()))
            self.marks.append(float(self.six.GetValue()))
            self.marks.append(float(self.seven.GetValue()))
            self.marks.append(float(self.eight.GetValue()))
            self.marks.append(float(self.nine.GetValue()))
            self.marks.append(float(self.ten.GetValue()))
            self.marks.append(float(self.eleven.GetValue()))
            self.marks.append(float(self.twelve.GetValue()))    
        
        self.average = int(sum(self.marks)) / float(12)
        my_avg = '%.2f' % (self.average)       
        wx.StaticText(self.panel,-1,str(my_avg),pos=(155,435) ).SetForegroundColour('blue') 
        
        
    def Quit(self,event):
        self.Close()

    def about(self,event):
        self.about=wx.AboutDialogInfo()

        self.about.SetName("Grade It!")
        self.about.SetCopyright("(c) 2009 Sravan")
        self.about.SetWebSite("http://www.uberpix.wordpress.com")
        self.about.AddDeveloper("Sravan")

        wx.AboutBox(self.about)

s_report()
window.MainLoop()
snippsat 661 Master Poster
def Done(self,event):
        
        self.marks=[] 
        
        self.marks.append(self.one.GetValue())
        self.marks.append(self.two.GetValue())
        self.marks.append(self.three.GetValue())
        self.marks.append(self.four.GetValue())
        self.marks.append(self.five.GetValue())
        self.marks.append(self.six.GetValue())
        self.marks.append(self.seven.GetValue())
        self.marks.append(self.eight.GetValue())
        self.marks.append(self.nine.GetValue())
        self.marks.append(self.ten.GetValue())
        self.marks.append(self.eleven.GetValue())
        self.marks.append(self.twelve.GetValue())
        
        print self.marks  #test print

I had a look at this,and something that wonder about.
Is why many GetValue() that is put in a list return a unicode list?

Here is the test print,just typed in four number.

[u'5', u'', u'', u'9', u'', u'7', u'', u'', u'', u'3', u'', u'']
snippsat 661 Master Poster
>>> from random import randint
>>> a = randint (1,10,)
>>> a
2
>>> b = randint (1,10,)
>>> b
5
>>> z = a + b
>>> z
7
>>> print (a, "+", b, "=")
2 + 5 =
>>> y = input('What is the answer?   ')
What is the answer?   7
>>> y
'7'
>>> #You see now that y is a string
>>> type(y)
<class 'str'>
>>> control = True
>>> control
True
>>> while control:
    if  int(y) == z:
        print ('Correct!')
        control = False
    while int(y) != z:
        y = input('Guess again!   ')

        
Correct!
>>> z = 2
>>> while control:
    if  int(y) == z:
        print ('Correct!')
        control = False
    while int(y) != z:
        y = input('Guess again!   ')

        
>>> #you see it not work if no  "y == z"

Try this.

from random import randint
a = randint (1,10,)
b = randint (1,10,)
z = a + b
print (z)
print (a, "+", b, "=")

while True:
    y = input('What is the answer?   ')
    if z == int(y):
        print ('Correct!')
        break
    else:
        print('try again')
snippsat 661 Master Poster

+/- thing?

Yes off course.
Python is very good to use to solve math problems.

Take a look at this

#First we import math
>>> import math
Then we look at what math has to offer.
>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'hypot', 'isinf', 'isnan', 'ldexp', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
#Then we can test it out.
>>> math.sqrt(9)
3.0
#Dont now what all this stuff do use doc strin " __doc__" and help
>>> math.radians.__doc__
'radians(x) -> converts angle x from degrees to radians'

>>> help(math.tan)
Help on built-in function tan in module math:

tan(...)
    tan(x)
    
    Return the tangent of x (measured in radians).

>>>

def quadratic(): function is maybe ok depend off you shall do.
But the rest is just wrong.

snippsat 661 Master Poster

Vegaseat has written a number to word converter.
http://www.daniweb.com/code/snippet216839.html
But at dont see why you should need this.

#Let look at dictionary for som simple number to word stuff.
>>> d
{1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten'}
>>> dir(d)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>> #now we can use dictionary method
>>> d.keys()
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> d.values()
['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
>>> d[1]
'one'
>>> d.has_key(4)
True
>>> d.has_key(12)
False
>>> #Noe let us convert number to word
>>> print 'Can you give my 1 in words,yes it is %s' % (d[1])
Can you give my 1 in words,yes it is one
>>>
snippsat 661 Master Poster

There are several big mistake yes.
And that use of global is not good at all.
Dont use global at all it`s ugly.

Test yout code in idle.
This is wrong.

Fraction('x \t\n')

Could be.

Fraction = ('x \t\n')

But it does not do what you want.

And this will never work.

print(fractions.Fraction(x), 'is fraction from + in +/-.') 
print(fractions.Fraction((-b-(b**2-4*a*c)**.5)/(2*a)), ' is fraction from - in +/-.')

And this what to say.

def intro2():
    global tocontinue, y, n, N, Y
    tocontinue = int(input('Again? (y/n))')
        if tocontinue == n:
            running = False
        else;
            running = True

Please test your code in idle, missing ")"(if not syntax error)

>>> tocontinue = int(input('Again? (y/n))'))
Again? (y/n))y
Traceback (most recent call last):
  File "<pyshell#33>", line 1, in <module>
    tocontinue = int(input('Again? (y/n))'))
ValueError: invalid literal for int() with base 10: 'y'

You use int here (input in python 3 return a string)

This is how it should have looked.

>>> tocontinue = input('Again? (y/n ')
Again? (y/n y
>>> tocontinue
'y'
>>>

And this i dont want to comment.

def intro():
    global running, intro3, y, Y
    while running:
        quadratic()
        answer()
        intro2()

So some more reading is smart.
Most stuff out there is for 2.x,so my advice is to use that to.
No problem to have both 2.x and 3.x installed.

For python 3.x
http://diveintopython3.org/
http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3.0

And a lot good info on this site.

snippsat 661 Master Poster

Like winmic says you need to use GetValue() in a method.
You have also "event.GetKeyCode()".
That can record live from keyboard.
But most normal is to have av button that collect data from user_input and do stuff.

Here a function(or method as is called when in a class)
This function collect user_input from 2 wx.TextCtrl.
And calculate the numbers from use_input and output to a wx.StaticText(SetLabel)

def button_click(self, event):         
    self.s1 = self.tex1.GetValue()
    self.s2 = self.tex2.GetValue()
    calculate = self.s1 * self.s2  
    self.l2.SetLabel (str(calculate))
snippsat 661 Master Poster

DaniWeb Community > Software Development > Python

So why are you posting java code here?

scru commented: Yeah, what the hell? +4
snippsat 661 Master Poster

Please use code tag so indents work.
Always read sticky post in top off a forum.

snippsat 661 Master Poster

Put this in and try again.

s=smtplib.SMTP("smtp.gmail.com",587)
s.ehlo()
s.starttls()
s.ehlo()
snippsat 661 Master Poster

There are several problem here.
Python 3.x only use input(raw_input only work for 2.x) = assign variable(can not use in = in a if statement. == Compares if the objects are equal

To get a integer to return you can do it like this.

number_of_courses = int(input ('Please enter...'))

This will not store variabls,so only last input will count.
Look at dictionary as woooee suggsest.

for number_of_courses in range (0, number_of_courses):
       major = raw_input('Enter class type') #cmsc, math, etc..
       coursenum = input('Enter course number')
snippsat 661 Master Poster

Hint.

for i in range(2, 1000):
	print i

>>> 2 % 2 == 0
True
>>> 3 % 2 == 0
False
>>> 4 % 2 == 0
True
>>> 5 % 2 == 0
False
>>>
snippsat 661 Master Poster

Print is good to use.
IDLE is good to use,to se what going on.

Just a little test

>>> import random
>>> WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone")
>>> word = random.choice(WORDS)
>>> word
'python'
>>> # So now we have a random word from tuple list

# This should give a random number from the word 'python'
>>> position = random.randrange(len(word))
>>> position
5
>>> # 5 is is "n" remember we count from 0
>>> word[position] # So this should now give "n"
'n'
>>>

Like this you can break upp the script to understand what happends.

snippsat 661 Master Poster

input was defined earlier in the code

Dont ever do that.

>>> input = 'hi'
>>> input
'hi'
>>> dir(input)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>>

Now input works as a string method.
And you can use input.find(),but this is very wrong.
Dont ever use build in python method as variables.

If you not sure use "my" before so my_input.

snippsat 661 Master Poster

input is a method that is build in to python.
And you can not do this input.find

>>> input.find

Traceback (most recent call last):
  File "<pyshell#53>", line 1, in <module>
    input.find
AttributeError: 'builtin_function_or_method' object has no attribute 'find'

>>> input('your number: ')
your number: 5
5

And comparing app,app1 to 1 is always false.

>>> app == 1
False
>>>
snippsat 661 Master Poster

What are you trying to do?

>>> first = 'stringisfun'
>>> second = 'iamsecond'
>>> app = first[0:8]
>>> app
'stringis'
>>> app1 = second[0:8]
>>> app1
'iamsecon'
>>> app + app1
'stringisiamsecon'
>>>

"and or" are used for decision control(Boolean logic)
So if you want both first and second to run that will never work.

#both test conditions are true and it print
>>> a = 4
>>> if a > 3 and a < 10:
	print 'this work'
	
this work

#if one is false it will not print
>>> if a > 3 and a > 10:
	print 'this work'


#if we use "or" only one test conditions has to be true.
>>> if a > 3 or a > 10:
	print 'this work'

this work
snippsat 661 Master Poster

indentations is 4 spaces,it work with 2 and 8 but never ever us anything else than 4.

A simple fix move line 8 so it get input from loop.
Remove set

import sys
result = []
f = open("sample_text.txt")
for line in f:
	for word in line.split():
		if word.startswith('h'):
			result.append(word)
                        result_length = len(result)
print "Total DISTINCT words starting with 'z': ", result_length

Here is the script with right indent,and som print to see what happends.

my sample_text.txt

hi this is an test.
hi again why not.
hi number 3.
result = []
f = open("sample_text.txt")
for line in f:
    for word in line.split():
        if word.startswith('h'):
            result.append(word)            
            print result  # use print as help easier to see what happends
            print len(result)  # use  print as help easier to see what happends      
print "Total DISTINCT words starting with '%s' is %d" % (result[0][0], len(result)) 

'''
my output-->
['hi']
1
['hi', 'hi']
2
['hi', 'hi', 'hi']
3
Total DISTINCT words starting with 'h' is 3
'''
vegaseat commented: very helpful +16
snippsat 661 Master Poster
>>> x = 813367.216157178627327
>>> x
813367.21615717863
>>> b = '%.2f' % x
>>> b
'813367.22'
>>> f = open('poly.txt', 'w')
>>> f.write(b)
>>> f.close()
>>> a = open('poly.txt', 'r')
>>> a.read()
'813367.22'
>>>
snippsat 661 Master Poster

Nice try.
But you have done some mistake.

lower = trick/2+low    #originally 250...
higher = trick+lower   #originally 750...

This is upp to the user,by typing 500,250.. to guess the number.
The user is doing a binary search

It was easier for me to write this than start edit your code.
Should help,mayby to much.
As a traning you could edit the code and make a function.
Set a argumet for max tries.
Som you can call it like this guess(10) # set max tries
So guess(15) will give 15 as max tries.

import random
number = random.randint(0, 1000)    
guess = 0
tries = 0

print'Guess a number(0,1000), max 10 tries'
while guess != number: 
    guess = int(raw_input ('my guess: '))       
    if guess < number:
        print('To low')
    elif guess > number:
        print('To high')
    tries += 1
    if tries >= 10:
        print'To many tries,the secret number was %s' % (number)        
        exit()        
print 'You guessed the secret number %s in %s tries' % (number, tries)
snippsat 661 Master Poster

Change to this.

items.Append(201,"Quit")
self.Bind(wx.EVT_MENU,self.Quit,id=201)
snippsat 661 Master Poster

Just a littel change from the good suggestion from woooee.
Type a letter:@
Never trust the user,there are always someone that dont follow instruction well.
If you want to look into this it`s called Exceptions handling
The other choice is to write the menu so that you dont need exceptions handling.

##--------------------------------------------------------------------------------------------------
## "select" is a python function and should not be used as a variable
selection = True
while selection:
    try:
        x = int(raw_input ('To convert Celsius to Farenheit, enter 1\nTo convert Farenheit to Celsius, enter 2\n'))   
        if x == 1:
            Tc_to_Tf ()
            selection = False
        elif x == 2:
            Tf_to_Tc ()
            selection = False
        else:
            print 'Only options are 1 or 2'
            
    except:
        print 'No letter please'
snippsat 661 Master Poster

Just to explain one thing look at vegaseat code.
Does it look like this line?

deck = ['%s of %s' % (n, s) for n in numbers for s in suits]

This is called list List Comprehensions
I can wite it like this.

deck = []
for n in numbers:
    for s in suits:
        card = '%s of %s' % (s, n)
        deck.append(card)

Then you see it not so differnt.

snippsat 661 Master Poster

Just to have some fun i build on sneekula Animal class.
Here the animal has name and it can eat and poop.

class Animal(object):
    def __init__(self, name, legs):
        self.name = name
        self.legs = legs
        self.stomach = []        
        
    def __call__(self,food):
        self.stomach.append(food)
    
    def poop(self):
        if len(self.stomach) > 0:
            return self.stomach.pop(0)
        
    def __str__(self):        
        return 'A animal named %s' % (self.name)        
        
        
cow = Animal('king', 4)
dog = Animal('flopp', 4)
print 'We have 2 animales a cow name %s and dog named %s,both have %s legs' % (cow.name, dog.name, cow.legs)
print cow  #here __str__ metod work

#We give food to cow
cow('gras')
print cow.stomach

#We give food to dog
dog('bone')
dog('beef')
print dog.stomach

#What comes inn most come out
print cow.poop()
print cow.stomach  #Empty stomach

''' output-->
We have 2 animales a cow named king and dog named flopp,both have 4 legs
A animal named king
['gras']
['bone', 'beef']
gras
[]
'''
snippsat 661 Master Poster

One way is like this
Take numbers and add like this "A" count as 1.

>>> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + 'Jack Queen King'.split()
>>> numbers
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King']
>>> 
>>> suits = ['diamonds', 'clubs', 'hearts', 'spades']
>>> suits
['diamonds', 'clubs', 'hearts', 'spades']

>>> deck = ['%s of %s' % (n, s) for n in numbers for s in suits]
>>> deck
# the hole deck

And we can make it look better.
>>> from pprint import pprint
>>> pprint(deck[:10])  #52 gives the hole deck
['1 of diamonds',
 '1 of clubs',
 '1 of hearts',
 '1 of spades',
 '2 of diamonds',
 '2 of clubs',
 '2 of hearts',
 '2 of spades',
 '3 of diamonds',
 '3 of clubs']
>>>
snippsat 661 Master Poster
def Tc_to_Tf ():
    Tc = input ("What is the Celsius Temperature ?   " )
    Tf = 9.0/5.0 * Tc + 32
    return Tf

Run it an nothing happends it only return Tf
Let do something simple in idle.

IDLE 2.6.2      
>>> Tf = 50
>>> print 'The temperature is %.2f Degrees Fahrenheit' % (Tf)
The temperature is 50.00 Degrees Fahrenheit
>>>

So the only diffrence is that we put function call i a variable. Tf = Tc_to_Tf ()

snippsat 661 Master Poster

Yes dont use global find other soultion like OOP.

Think of function like a black box you can only put in variabels and return variabels out.
Then you can use your function anywhere in your code.
It dont leak out in global space.

Think always about design of your code.
Say u have a global variabel that you want to doubble opp.

global_var = 10

def doubble(x):
    return 2 * x  

new_global = doubble(global_var)
print new_global  #20

Function doubble(x) er invulnerable and you can use it anyware in you code.

snippsat 661 Master Poster

To round off decimal

IDLE 2.6.2      
>>> 0.0225
0.022499999999999999
>>> round(0.0225, 3)
0.023
>>> round(0.0225, 2)
0.02

>>> a = 15.1548
>>> print '%.2f' % a
15.15

>>> print '%.3f' % a
15.155

#Look at type
>>> s = '1.458045577554545454'
>>> type(s)
<type 'str'>

 >>> x = 1.458045577554545454
>>> type(x)
<type 'float'>

>>> y = 54
>>> type(y)
<type 'int'>

#Let try round on a string
>>> s = '1.458045577554545454'
>>> s
'1.458045577554545454'
>>> round(s, 2)

Traceback (most recent call last):
  File "<pyshell#70>", line 1, in <module>
    round(s, 2)
TypeError: a float is required

#Ok a float is required
>>> b = float(s)
>>> b
1.4580455775545456
>>> round(b, 2)
1.46
snippsat 661 Master Poster

so why doesn't it (the code above) work?

Why shoud it?
Break it thing down to understand what happends.

>>> class my_class:
	def __init__ (self):
		self.name = ' my name is hi'
		
>>> a = my_class()  #Class instance
>>> print a
<__main__.my_class instance at 0x011E23F0>
>>> 
# This only show the class instance and memory location.
# So you see now that your code can not work.

>>> a.name  #call __init__(constructor)
' my name is hi'

>>> my_list= ['a','b']
>>> for x in my_list:
	print a.name, x	
 my name is hi a
 my name is hi b

This dosent make must sense.

Just one way that give a little more sense.
----------------
my_list= ['a','b']

class my_class:    
    def __init__ (self, name):
        self.name = name       

a = my_class('Tom')

for x in my_list:
    print 'Hi %s my name is %s' % (a.name, x)

output-->
Hi Tom my name is a
Hi Tom my name is b
----------------
snippsat 661 Master Poster
snippsat 661 Master Poster

try.
if shotsum > self .old_leader:

Can you post participants.txt Or just a part of it,so we can se format that goes inn.

snippsat 661 Master Poster

if word not in never_save.readlines():
You need : or SyntaxError.

snippsat 661 Master Poster

Yes most books tutorial are for 2.x
No problem to have both installed 2.x and 3.x installed

No problem to read 2.x books/tutorial you are learing 3.x then to,they difference is not that big.

To say it simple there are to much code 2.x that will help you that just using 3.x would not be smart.
Like this great post for beginner on this site.
http://www.daniweb.com/forums/thread20774.html

2to3 module er working great to(converts 2.x to 3.x code)
Many 3parts module works just for 2.x(wxpython,py2exe,pygame...)

Take it easy and use both 2.x and 3.x it`s thats`s the best advice.

Byte of python and dive into python has come out for 3.x
http://www.swaroopch.com/notes/Python
http://diveintopython3.org/

Books 3.x
http://www.amazon.com/Programming-Python-Complete-Introduction-Language/dp/0321680561/ref=sr_1_16?ie=UTF8&s=books&qid=1250948572&sr=1-16
http://www.amazon.com/Python-Absolute-Beginners-Tim-Hall/dp/1430216328/ref=sr_1_2?ie=UTF8&s=books&qid=1250948511&sr=1-2