snippsat 661 Master Poster

One more way.

while True:
    try:
        wd = int(input('How wide would you like your letter to be? (5-20)' + ': '))
        if wd <=20 and wd >= 5:
            print ('You have answered: %s' % wd)
            break
        else:
             print('please enter a value between(5-20)')
    except (ValueError,NameError,SyntaxError):
        print ("Oops! That was no valid number. Try again...")
snippsat 661 Master Poster

Input in python 3 return datatype string(same as raw_input in python 2.x)

Change to datatype you need when you calculate.

print(add1, "+", add2, "=", int(add1) + int(add2))
print(div1, "/", div2, "=", float(div1) / float(div2))
snippsat 661 Master Poster

ip = str(DEVICE_IP) .spilt('.') .
Spelling error.
ip = str(DEVICE_IP).split('.')

Alternative print line.

print '%s-%s-%s-%s' % (ip[0],ip[1],ip[2],ip[3])
snippsat 661 Master Poster

Ok here you go,read a little more about dictionary an basic stuff;)

pairs =\
{"Jeremy": "Jerome",
 "Jason": "Fred",
 "Joe" : "Fred",
 "Alayna" : "Tom",
 "Jay" : "Jerome",
 "April" : "Tom"}

def find_father():    
    print "\n This is your current list \n\n", pairs.keys() #We print only sons name 
    choice_name = raw_input("Please enter a Name: ")
    if choice_name in pairs:
        print 'Father of %s is %s ' % (choice_name, pairs[choice_name])        
    else:
        print 'Name not in database'
    raw_input("\nTrykk enter for meny\n")   

def main():
    '''Main menu and info ''' 
    while True:               
        print 'Father finder'
        print '(1) Find a Father'        
        print '(q) Quit' 
        choice = raw_input('Enter your choice: ') 
        if choice == '1':
            find_father()       
        elif choice == 'q': 
            return
        else: 
            print 'Not a correct choice:', choice 

if __name__ == '__main__':
    main()
snippsat 661 Master Poster

Hint.

>>> choice_name = 'Jay'
>>> if choice_name in pairs:
...     print 'Father name is %s' % pairs[choice_name]
...     
Father name is Jerome
>>>
snippsat 661 Master Poster

Use code tag next time,not quote tags.
Look at this code ande try to write the rest(if-else)

pairs =\
{"Jeremy": "Jerome",
 "Jason": "Fred",
 "Joe" : "Fred",
 "Alayna" : "Tom",
 "Jay" : "Jerome",
 "April" : "Tom"}


def find_father():    
    print "\n This is your current list \n\n", pairs.keys() #We print only sons names
    pass      

def main():
    '''Main menu and info ''' 
    while True:               
        print 'Father finder'
        print '(1) 1 - Find a Father'        
        print '(q) Quit' 
        choice = raw_input('Enter your choice: ') 
        if choice == '1':
            find_father()       
        elif choice == 'q': 
            return
        else: 
            print 'Not a correct choice:', choice 

if __name__ == '__main__':
    main()
snippsat 661 Master Poster

Somthing like this,i make a mark_check() function.
Use exception handling to catch wrong input.

Not much wrong with you code just test the if-elif-else condition to get the result you want.

def calcFinal():
    while True:
        try:
            asg1Mark = int(raw_input("Enter Asg1 mark: ")) 
            asg2Mark = int(raw_input("Enter Asg2 mark: ")) 
            examMark = int(raw_input("Enter Exam mark: ")) 
            final = asg1Mark + asg2Mark + examMark         
            return final
        except ValueError:
            print 'Only numbers,try again'

def mark_check(finalMark):
    print "Final mark is %d, grade is" % finalMark,  
    if finalMark < 50: 
        print "Fail"
    elif finalMark <= 65:
        print "Pass"
    elif finalMark <= 75:
        print "credit"
    elif finalMark <= 85:
        print "Distinction"
    elif finalMark >= 85:
        print "High Distinction"   
    else:
        print "Invaild selction"

def main():
    finalMark = calcFinal() 
    mark_check(finalMark)

if __name__ == "__main__":
    main()
snippsat 661 Master Poster

Change the code with and try-except block,so it dont crash when letter is the input.

def dec():
    while True:
        try:
            x = float(raw_input('enter number:  '))
            if x % 1 == 0:
                print ("The number entered must be a decimal number")
            else:
                return x
        except ValueError:
            print 'Numer only'       
dec()
snippsat 661 Master Poster

The code it is not tested, but should be worked

You should test it because it is not working:-/

Here you have one way off do it.
This is for python 3 that i think you use.
Homework?,they may spot that you havent wirte this code(some smart shortcut in this code)
You may work on the for loop you startet with(now your code is not working)

def makeList():
    num = input('Please enter the number of strings you want to input\n')
    alist = []
    for i in range(int(num)):
        x = input('Enter string please: ')
        alist.append(x)
    return sorted(alist)

def findShortest(alist):
    min_list = min(alist, key=len)
    return (min_list)

def findLongest(alist):
    max_list = max(alist, key=len)
    return max_list

def findAlpha(alist):
    alpha_list = [item for item in alist if str(item).isalpha()]
    return alpha_list

def main():
    alist = makeList()
    print ('Sorted list is:\n{0}'.format(alist))
    print ('Shortest element is:\n{0}'.format(findShortest(alist)))
    print ('Longest element is:\n{0}'.format(findLongest(alist)))
    print ('Only alphabetic characters is:\n{0}'.format(findAlpha(alist)))

if __name__ == "__main__":
    main()

'''Out-->
Sorted list is:
['car', 'taxi', 'train5']
Shortest element is:
car
Longest element is:
train5
Only alphabetic characters is:
['car', 'taxi']
'''
vegaseat commented: nice code +10
snippsat 661 Master Poster

Tkinter has an native an rather ugly look on windows.
Use another tool kit like wxpython(my favorite) or PyQt.
They look good on windows and have more lot option for creating good looking GUI.

snippsat 661 Master Poster

Yes i have to wait for 3 party libraries to be ported to python 3.x.
Like wxpython very much so have to wait for that to by portet to python 3.x
Have off course python 3.x installed to look at changes.

Twistet i think will not be ported to python 3.x before 2015.
I think there is no problem at all to stay with python 2.x,if project that not need 3 party libaryes then man can use python 3.x

snippsat 661 Master Poster

if i want to delete red data of only key '172.14' all in from array

You can use vega code for this.

mylist = newlist
print(mylist)

So now mylist has removed item you want(garbage collection)old mylist do not exits.

Or an another soultion.

mylist = [
'192.168.255.1 00:01:02',
'172.14.0.1 00:0f:01',
'172.14.0.2 00:0f:01',
'172.14.0.3 00:0f:01'
'172.14.0.4 01:ff:dd:34',
'192.168.255.3 00:dd:01:ff'
]

for item in mylist[:]:
    if item.startswith('172'):        
        mylist.remove(item)   
        
print mylist
snippsat 661 Master Poster
word1 = 'This is my car'
word2 = 'My car is fine' 

diff_list = []
for item in word1:
    if not item in word2:
        diff_list.append(item)

print diff_list

And for index that i forget we can use vega code with a litte twist.

word1 = 'This is my car'
word2 = 'My car is fine' 

diff_list = []
for item in word1:
    if not item in word2:
        diff_list.append(item)

print diff_list

for letter in diff_list:
    index = str(diff_list).find(letter)    
    print( "letter %s is at index %s" % (letter, index))

'''Out-->
['T', 'h', 'm']
letter T is at index 2
letter h is at index 7
letter m is at index 12
'''
snippsat 661 Master Poster
def common_letter():
        #word1 = raw_input("Enter word1: ")
        #word2 = raw_input("Enter word2: ")
        word1 = 'This is my car'
        word2 = 'My car is fine'        
        
        li1 = []
        li2 = []
        for letter1 in word1:
                li1.append(letter1) #This is better
        for letter2 in word2:
                li2 += letter2
        print li1  #Now you have two list with the word
        print li2  #And nothing is compared 
        
        diff_list = [item for item in li1 if not item in li2]
        #Can write it as a loop if this is hard to understand
        print diff_list 
       
common_letter()
snippsat 661 Master Poster

That is making it more difficult than it need to be Tech B.

n = raw_input('enter a number: ')
first_n = int(n[0])
print first_n
snippsat 661 Master Poster

Look at Gui2exe to.
Dos not create console default.

snippsat 661 Master Poster

This was very bad,not worth anyone times.
The gui builder for wxpython could be better,but they are much better than this.

snippsat 661 Master Poster

It just gave a message at the bottom of the gray PythonWin frame right where it says,"running the code file..." or something similar to that

Get a better editor than PythonWin.
Pyscripter is good.
Paste your kode inn,and you se a red line mark under line 7 for your code.
It also give you and postion(25) if you try to run the code.
Because at postion(25) there should be a : as Gribouillis pointet out.

snippsat 661 Master Poster

You dont need to use ; in python.

First we breake it down in python IDLE.

IDLE 2.6.4      
>>> exp = "1+2"
>>> exp
'1+2'
>>> string1 = exp.split("+")
>>> string1
['1', '2']
>>> print "Operator 1 is : " , op1
Operator 1 is : 

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    print "Operator 1 is : " , op1
NameError: name 'op1' is not defined
#just to get and error message "NameError" because we have nor defiend op1.

>>> print "Operator 1 is: %s  " % string1[0]
Operator 1 is: 1

So the finish script.

def start():
    exp = "1+2"
    string1 = exp.split("+")
    
    print "Operator 1 is: %s" % string1[0]
    print "Operator 2 is: %s" % string1[1]
    
start() 

'''Out-->
Operator 1 is: 1
Operator 2 is: 2
'''
snippsat 661 Master Poster

You can look at this,for taking out values.

l = []
for i in open('your.txt'):
    l.append(i[0:2])
    
print l
l1 = l[0]
print l1

'''Out-->
['10', '12', '4,']
10
'''
snippsat 661 Master Poster

You dont need two //,only if it is this way \\.

So this will work on windows.
os.system("myprog /mydir_where_there_is_xm/myxml.xml")

snippsat 661 Master Poster

absolute and relative paths.

Rember to use \\ or /(windows)
\ count as a new line.

So as an example.
c:/tmp/163282.xml
or
c:\\tmp\\163282.xml

snippsat 661 Master Poster

For help you have to post your code,we can not guess how your code are set up.

snippsat 661 Master Poster

How dos your money.txt look?

Change to this money = int(money) - Bet .

Type check print type(money) . print type(Bet) Your desgin could be better, a long funtion that only ends(no loop)
Try to make a main function that has meny and question then that function call the bet function.
Betting is done and it goes back to main.

snippsat 661 Master Poster

Use this f = open('C:/teste.txt', 'w') .
Or this f = open('C:\\teste.txt', 'w') . \ count as newline \\ == Backslash (\)

In windows i always use this c:/ .
http://docs.python.org/reference/lexical_analysis.html#string-literals

snippsat 661 Master Poster

From command line.

C:\>python -m timeit "for i in xrange(100): pass"
1000000 loops, best of 3: 1.77 usec per loop

#Are tuple faster than list?
C:\>python -m timeit (1,2,3,4)
10000000 loops, best of 3: 0.0226 usec per loop

C:\>python -m timeit [1,2,3,4]
10000000 loops, best of 3: 0.194 usec per loop
#Yes tuple are faster than list
snippsat 661 Master Poster

In first post.

After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on a project you are interested in.

That means that you have to know python good.
You can still be a beginner after 1-3 year it depends how much time you put in to learning programming.

Python is on the most easy language to learn,but it take time to be a good programmer where you can solve problem on your own(without hours on google for the most basic thing)

To day people are in a hurry to learn,this is a good read.
Teach Yourself Programming in Ten Years

snippsat 661 Master Poster
>>> import time
>>> dir(time)
['__doc__',
 '__name__',
 '__package__',
 'accept2dyear',
 'altzone',
 'asctime',
 'clock',
 'ctime',
 'daylight',
 'gmtime',
 'localtime',
 'mktime',
 'sleep',
 'strftime',
 'strptime',
 'struct_time',
 'time',
 'timezone',
 'tzname']
>>> help(time.sleep)
Help on built-in function sleep in module time:

sleep(...)
    sleep(seconds)
    
    Delay execution for a given number of seconds.  The argument may be
    a floating point number for subsecond precision.

>>>
snippsat 661 Master Poster

So first you do something like this.

html = '''\
<HEADLINE text="This is headline 1">
<PARAGRAPH file="path to the file.txt">'''

l = []
for item in html.split('\n'):
    if item.startswith('<HEADLINE'):
        l.append(item.split('"')[1])
        ll = ''.join(l)
print ll
'''Out-->
This is headline 1
'''

And then you want that text to go in a new html code?
Eksp. <p>This is headline 1p> .

To take out elements from webpages look at.
BeautifulSoup and lxml

snippsat 661 Master Poster

That code work.
You have off course to have image in same folder as you run your.py file from.

Or give it correct path name to file.
bground = wx.Image('c:/myfolder/sonic.gif',wx.BITMAP_TYPE_ANY)

snippsat 661 Master Poster

Look like you use python 3

>>> #Python3 has only input that return a string
>>> user_input = input('Give me a number: ')
Give me a number: 10
>>> user_input
'10'
>>> type(user_input)
<class 'str'>
>>> print 'Your number was %s' % (user_input)
SyntaxError: invalid syntax (<pyshell#4>, line 1)
>>> print ('Your number was %s' % (user_input))
Your number was 10
>>> #And print has become function print()
>>>
snippsat 661 Master Poster

Not possible to help you if you dont post the code.

Look at this.
http://wxpython.webs.com/tutorial5.htm

Install wxpython demo.
I have made put files in folder named c:\demo.
To start python c:\demo\demo\demo.py

snippsat 661 Master Poster

For loop will only iterate one time over the list and not find duplicated words.

You can use text.find() method in a while loop.
This will iterate over all word in the text, when all search word are found text.find() will return -1.

Example.

text = """\
Hi,i have a nice car.
I drive to work every day in my car.
This text will find my car,....car.
"""

search_word = "car"
found = text.find(search_word)
while found > -1:
     print search_word, "found at index", found
     found = text.find(search_word, found + 1)

'''Out-->
car found at index 17
car found at index 54
car found at index 82
car found at index 90
'''
deonis commented: Very clear answer +1
snippsat 661 Master Poster

And dont mix indentation now you have 8 spaces and 2 spaces.
Always use 4 spaces.
Look at PEP 8

snippsat 661 Master Poster

The autorun.inf file has to be on your usb/cd/dvd drive.
Or nothing will start.

Your exe file you can have on your pc.
Just set path in your autorun.inf
Eksp.
open = c:/my_backup/backup.exe

snippsat 661 Master Poster

If you make a script that do what you want, and then use py2exe.
It should be possible to to it like this.

[autorun]
open = Your_py2exe_file.exe
action = Run my program
icon = your.ico

Save as autorun.inf in your root usb drive.
You also have tool like PStart that you can use.
http://www.pegtop.de/start/

snippsat 661 Master Poster

Use code tag now we can not see if your indentation is correct.

You dont have strip() in your script.

>>> a = 'test      \n'
>>> len(a)
11
>>> #Without whitespace and new line
>>> b = a.strip()
>>> b
'test'
>>> len(b)
4
>>>

So you read in file(for loop) strip() it and use len() to find word that has more than 20 characters.

fin = open('c:/python26/words.txt')

for line in fin:
    word = line.strip()
    if len(word) > 20:
        print word
'''--> Output
counterdemonstrations
hyperaggressivenesses
microminiaturizations
'''
snippsat 661 Master Poster

You can do that with most gui toolkit.
Wxpython is the most populare on this forum.
Look at sticky at top for example off gui toolkit for python.
http://zetcode.com/wxpython/menustoolbars/

snippsat 661 Master Poster

A coulpe of class that show __str__ and __repr__ methods.

import datetime

class Time(object):
    def __init__(self,date):
        self.date = date
        
    def __str__(self):
        """Return a pleasant representation."""
        return 'Return a human-readable string: %s' % (self.date)    
    

t = Time(datetime.date.today())
print t  #The __str__ method of a class is called whenever Python needs a string representation of an object
'''
Return a human-readable string: 2009-12-27
'''
class Time(object):
    def __init__(self,date):
        self.date = date       
        
    def __repr__(self):
        '''We use __repr__ to produce a clear definition of how to recreate the given object'''
        return 'Return an expression: %r' % (self.date)    

t = Time(datetime.date.today())
print t
'''
Return an expression: datetime.date(2009, 12, 27)
'''

Navigate and getting help

>>> dir(datetime)
['MAXYEAR', 'MINYEAR', '__doc__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo']
>>> dir(datetime.date)
['__add__', '__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', 'ctime', 'day', 'fromordinal', 'fromtimestamp', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'min', 'month', 'replace', 'resolution', 'strftime', 'timetuple', 'today', 'toordinal', 'weekday', 'year']
>>> dir(datetime.date.today)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
>>> #There are no more methods only special method that get called when you use the class

>>> #we look at __doc__
>>> print datetime.date.today.__doc__
Current date or datetime:  same as self.__class__.fromtimestamp(time.time()).
>>> #Or you can use help

>>> help(datetime.date.today)
Help on built-in function today:

today(...)
    Current date or datetime:  same …
snippsat 661 Master Poster

You have to understand the basic of wxpython.
Then you use only the part of code that you need.

Examlpe.

import wx

class MyFrame(wx.Frame):
    '''info abot class | Doc string'''
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
         
        #---| Window color |---#
        self.SetBackgroundColour('light blue')
        
        #---| Panel for frame |---#
        self.panel = wx.Panel(self)       
        

if __name__ == "__main__":
    app = wx.App()   
    mytitle = 'My window'  
    width = 300
    height = 200
    MyFrame(None, mytitle, (width, height)).Show()
    app.MainLoop()

Now i have a basic window.
So start wxpython demo.
I what to use choicebox code from demo.
Now i only copy the part i need,not all demo code.

import wx

class MyFrame(wx.Frame):
    '''info abot class | Doc string'''
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
         
        #---| Window color |---#
        self.SetBackgroundColour('light blue')
        
        #---| Panel for frame |---#
        self.panel = wx.Panel(self)          
        
        #Demo code
        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']        
        #Demo code
        self.ch = wx.Choice(self.panel, -1, (100, 50), choices = sampleList)
        self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch)

    #Demo code 
    def EvtChoice(self, event):
        a = event.GetString()  #I change event handling like this i dont wanne write out like in the demo      
        self.a = wx.StaticText(self.panel, -1, str(a), pos = (105,80))  

if __name__ == "__main__":
    app = wx.App()   
    mytitle = 'My window'  
    width = 300
    height = 200
    MyFrame(None, mytitle, (width, height)).Show()
    app.MainLoop()
snippsat 661 Master Poster

It`s better that you make a simple class and post that code.
Then ask what you dont understand.

If you dont now how to make a class at all,read some tutorials or seek google.

snippsat 661 Master Poster

If you look at this post,i give some example.
http://www.daniweb.com/forums/thread245633.html

snippsat 661 Master Poster

See if this help you.

def colourPicker():
    print "pick four different colours from; red, green, blue, yellow, orange, pink, brown"
    colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"]
    chosenColours = []
    count = 0
    while True:            
        colourPicked = raw_input("pick a colour: ")
        if colourPicked in colourList:
            chosenColours.append(colourPicked)
            if len(chosenColours) == 4:  #If length of list is 4 do next line
                break  #For test we use break this is what you will do "return chosenColours" 
            else:
                count +=1
                print 'Color %d is picked and it is %s ' % (count,chosenColours)           
        else:
            print 'Not in list'       
    print chosenColours    

colourPicker()
'''-->output
pick four different colours from; red, green, blue, yellow, orange, pink, brown
pick a colour: ghgh
Not in list
pick a colour: red
Color 1 is picked and it is ['red'] 
pick a colour: green
Color 2 is picked and it is ['red', 'green'] 
pick a colour: pink
Color 3 is picked and it is ['red', 'green', 'pink'] 
pick a colour: brown
['red', 'green', 'pink', 'brown']
'''
snippsat 661 Master Poster

You have made a function that dont get passed(and argument) and it dont return anything as your description say.

First the easy way with a build in(sum)

def sum_lst(my_list):
    return sum(my_list)

num = [1,2,3]  
print sum_lst(num)  #6

Here function is passes a list(num) and return the sum.
And i think this is homework,so you may have to use a while loop.

def sum_elements(my_list):
    total = 0
    index = 0
    while index < len(my_list):
        total += my_list[index]
        index += 1
    return total
 
num = [1,2,3]
print sum_elements(num)  #6

Next time use code tag and look more at how argument and return in a function works.

snippsat 661 Master Poster

http://docs.python.org/library/exceptions.html
http://python.about.com/od/pythonstandardlibrary/a/lib_exceptions.htm
Use python shell as postet on top.

>>> import exceptions
>>> dir(exceptions)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '__doc__', '__name__', '__package__']
>>>
snippsat 661 Master Poster

What Is an Exception?

Python uses exception objects.
When it encounters an error, it raises an exception.
If such an exception object is not handled (or caught), the program
terminates with a so-called traceback (an error message)

>>> b

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    b
NameError: name 'b' is not defined
>>>
import exceptions
>>> dir(exceptions)
<list method in exception class>

So let try it out. Version 1

x = input('Enter the first number: ')
y = input('Enter the second number: ')
print x/y 
'''
Enter the first number: 10
Enter the second number: 5
2
'''

Work just fine. Version 2

x = input('Enter the first number: ')
y = input('Enter the second number: ')
print x/y
'''
Enter the first number: 10
Enter the second number: 0
Traceback (most recent call last):
  File "E:\1py\Div\dffddd.py", line 3, in <module>
    print x/y
ZeroDivisionError: integer division or modulo by zero
'''

Here we got an problem,user did divided 10/0.
So what to do now?
We have to catch that exceptions.
You do this with the try/except statement. Version 3

try:
    x = input('Enter the first number: ')
    y = input('Enter the second number: ')
    print x/y
except ZeroDivisionError:
    print "Dont divid by zero!"
'''
Enter the first number: 10
Enter the second number: 0
Dont divid by zero!
'''

Look we used ZeroDivisionError from error message,and now we dont get …

snippsat 661 Master Poster

Two module comes in mind.

Python Win32 Extensions.
http://python.net/crew/skippy/win32/Downloads.html
Tim Golden's excellent WMI.
http://tgolden.sc.sabren.com/python/wmi/index.html

WMI has an excellent way of looking at many hardware settings,
but has limited support for changing many of them.

Try pypi to see if someone has make somthing for this.
http://pypi.python.org/pypi

Maybe better to find a network soultion(something like you have now)
So low level as disabling hardware devices can be a problem,but very few thing are impossible.

snippsat 661 Master Poster

Have make a better menu system.
Put all comment in doc string.

Look at exception handling for your function.
Try type a letter.

def getPints(pints):
    '''The getPints(pints) function:'''
    counter = 0
    while counter < 7:
        pints[counter] = input ("Enter pints collected: ")
        counter = counter + 1
    return pints

def getTotal(pints, pintsTotal):
    '''The getTotal(pints, pintsTotal) function:'''
    counter = 0
    while counter < 7:
        pintsTotal = pintsTotal + pints[counter]
        counter = counter + 1
    return pintsTotal

def getAvg(pintsTotal, pintsAvg):
    '''The getAvg(pintsTotal, pintsAvg) function:'''
    pintsAvg = pintsTotal / 7
    return pintsAvg

def getHigh(pints, pintsHigh):
    '''The getHigh(pints, pintsHigh) function:'''
    pintsHigh = pints[0]
    counter = 1
    while counter < 7:
        if pints[counter] > pintsHigh:
            pintsHigh = pints[counter]
            counter = counter + 1
        return pintsHigh

def getLow(pints, pintsLow):
    '''The getLow(pints, pintsLow) function:'''
    pintsLow = pints[0]
    counter = 1
    while counter < 7:
        if pints[counter] < pintsLow:
            pintsLow = pints[counter]
            counter = counter + 1
        return pintsLow

def dispInfo(pintsTotal, pintsAvg, pintsHigh, pintsLow):
    '''Function to display the information:'''
    print "The total number of pints donated was: ", pintsTotal
    print "The highest number of pints donated was: ", pintsHigh
    print "The lowest number of pints donated was: ", pintsLow
    print "The average # of pints donated was %.2f " % (pintsAvg) #display float with 2 decimal
    return

def main():
    '''Main menu and info '''            
    while True:               
        print 'Welcome to my menu\n'
        print '(1) Calculate pints'
        print '(2) Display pints info'
        print '(q) Quit' 
        choice = raw_input('Enter your choice: ') 
        if choice == '1':
            # …
snippsat 661 Master Poster

You have to study and learn the basic of function,now it`s no god.
Run this the first function and understand what is dos.
Here i make sure that number are between 1-6.

import random  #import shall alway be first

def get_user_choice():   
    while True:
        try:          
            user_choice = int(raw_input('Type a number, 1 to 6: '))
            if user_choice <=6 and user_choice >= 1:
                print user_choice   #test print                
                #return user_choice #we return and this exit this function when number is between 1-6
                break  #we break out off loop.                         
            else:
                print 'Numbers most be between 1 and 6'       
        except ValueError:
            print 'Only numbers'    

get_user_choice()

Now with return.
Think of how this work,now this function is returning user_choice.
Then this function has done it`s work

Then you catch that variable in your next function.
To do more work with variable user_choice
def check_if_true( user_choice ):

def get_user_choice():   
    while True:
        try:          
            user_choice = int(raw_input('Type a number, 1 to 6: '))
            if user_choice <=6 and user_choice >= 1:                              
                return user_choice #we return and this exit this function when number is between 1-6
            else:
                print 'Nubmer most be between 1 and 6'       
        except ValueError:
            print 'Only numbers'
snippsat 661 Master Poster

I'm really surprised and disappointed to see that no body has replied even after two days of posting the question... Does daniweb forum slowly losing it's fervour and it's uniqueness???

Maybe because this is a jobb for goolge.

http://diotavelli.net/PyQtWiki
And on this site.
http://www.daniweb.com/forums/thread191210.html