Search Results

Showing results 1 to 40 of 78
Search took 0.05 seconds.
Search: Posts Made By: snippsat ; Forum: Python and child forums
Forum: Python 4 Days Ago
Replies: 2
Views: 208
Posted By snippsat
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...
Forum: Python 11 Days Ago
Replies: 5
Solved: except
Views: 319
Posted By snippsat
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)...
Forum: Python 11 Days Ago
Replies: 5
Solved: except
Views: 319
Posted By snippsat
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...
Forum: Python 11 Days Ago
Replies: 5
Views: 202
Posted By snippsat
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:'''
...
Forum: Python 20 Days Ago
Replies: 10
Views: 358
Posted By snippsat
Is it not better to make one function like this to add 2 number.

def add_number():
n = raw_input('Enter number to add format (2+2)')
num1, num2 = n.split('+')
my_sum = int(num1) +...
Forum: Python 20 Days Ago
Replies: 10
Views: 358
Posted By snippsat
Look at this here two way to work with function.
Maybe you get some idèe on how to solve your +*-/ with function and a menu.
One function i just return and do calulation in main.
They other...
Forum: Python 20 Days Ago
Replies: 10
Views: 358
Posted By snippsat
Two classes with 1 attributt(variable) in each,is not a normal OO design.
Your program work,but for me this is not a good way to code.

Some problem.
Menu should come first so user now what this...
Forum: Python 22 Days Ago
Replies: 14
Views: 531
Posted By snippsat
Tkinter is the build in gui(Graphical user interface) of python.
There are many other good gui toolkit like wxpython - PyQt -PyGTK.


No Tkinter or any other gui toolkit is to display our python...
Forum: Python 24 Days Ago
Replies: 9
Solved: variables
Views: 465
Posted By snippsat
The example is simple and you shoul try to understand it.
Break it down and ask question.

def get_data():
"""get the data from the user, from a file, or hard coded"""
mydata = [1, 2, 3,...
Forum: Python 26 Days Ago
Replies: 15
Solved: Scorecard
Views: 527
Posted By snippsat
Maybe,but i wont speend any tïme at all on an outdatet module like graphics.py.
It was just made as an intro to graphic,you much forget this module if you want to make something ourself.

Look at...
Forum: Python 26 Days Ago
Replies: 15
Solved: Scorecard
Views: 527
Posted By snippsat
You should not speend much time on outdate mouduls like graphics.py.
Think it was written in 2005 by John M. Zelle as and easy intro to graphics for beginner.

The only way to do this is to learn...
Forum: Python 29 Days Ago
Replies: 14
Views: 556
Posted By snippsat
Do you think we can se your code based on output print screen?
If you want help you post your code or the part you think cause the problem.
Forum: Python 29 Days Ago
Replies: 9
Solved: IDE for PyQt..
Views: 537
Posted By snippsat
You can use what ide editor you want, whish gui toolkit you use dos have little impact.

Pyscipter is good.
http://code.google.com/p/pyscripter/

I use komodo ide,and pyscripter for python 3.x...
Forum: Python 29 Days Ago
Replies: 14
Views: 556
Posted By snippsat
Dictionary values are accessed by their key. To allow for high speed key searches, the keys are in a hash order. So a dictionary sorted alphabetically by it's keys would make no sense and would...
Forum: Python 30 Days Ago
Replies: 10
Views: 419
Posted By snippsat
>>> import webbrowser
>>> dir(webbrowser)
['BackgroundBrowser', 'BaseBrowser', 'Elinks', 'Error', 'Galeon', 'GenericBrowser', 'Grail', 'Konqueror', 'Mozilla', 'Netscape', 'Opera', 'UnixBrowser',...
Forum: Python 30 Days Ago
Replies: 10
Views: 562
Posted By snippsat
Kind off help whit some clear messages.
>>> we_dot_do_homework_if_no_effort_is_shown = 2
>>> 1 % we_dot_do_homework_if_no_effort_is_shown
1
>>> 2 % we_dot_do_homework_if_no_effort_is_shown
0...
Forum: Python Nov 17th, 2009
Replies: 5
Views: 312
Posted By snippsat
Vegaseat has pretty much given you the answer.
You dont say that code dos not work and nothing more.
Then is not possibly to help you,post your code and then you say it will not work or try to...
Forum: Python Nov 17th, 2009
Replies: 2
Views: 258
Posted By snippsat
If you what this result is better to iterate over the list and append the result to a new list.

L = [ 0 , 2, 1 , -1 , -1 , -1, -1 ]

new_list = []
for item in L:
if item >= 0:
...
Forum: Python Nov 17th, 2009
Replies: 4
Views: 254
Posted By snippsat
Tkinter has change import name in python 3.
Put this first then tkinter import correct for python 2.x and 3.x
try:
# for Python2
import Tkinter as tk
except ImportError:
# for...
Forum: Python Nov 15th, 2009
Replies: 9
Views: 352
Posted By snippsat
New style class python 2.2--> you should use class(object):
Old style pre python 2.2 class:

So object is a build in,let`s test it.
IDLE 2.6.2
>>> object
<type 'object'>
>>>

For more...
Forum: Python Nov 13th, 2009
Replies: 12
Solved: pizza delivery
Views: 378
Posted By snippsat
Yes as it should do,is should not be so hard to understand.
<= 10 means that less than 10 or equal to 10 it will add 1.50.
Then off course if you input is 10 it will add 1.50 and print 11.50.
< 10...
Forum: Python Nov 12th, 2009
Replies: 11
Views: 545
Posted By snippsat
It`s not the best example of python class masterofpuppets.
You put in lot effort to help wish is fine.


Python is not java,it`s a lot better:cool:...
Forum: Python Nov 12th, 2009
Replies: 12
Solved: pizza delivery
Views: 378
Posted By snippsat
Yes,i should have think of that you need floating point number to get correct sum.
%.2f(give you 2 decimal float number)

is %.2f pounds" % (order + x)
Forum: Python Nov 12th, 2009
Replies: 12
Solved: pizza delivery
Views: 378
Posted By snippsat
order = input("Please enter the price of the order: ")
x = 1.50
if order < 10:
print "the total price including the delivery charge is %d pounds" % (order + x)
else:
print "The toal...
Forum: Python Nov 9th, 2009
Replies: 7
Views: 307
Posted By snippsat
>>> #Is rounds greater than player_point or cpu_point
>>> #It will print Victory
>>> #Test
>>> rounds = 5
>>> player_point = 4
>>> cpu_point = 3
>>> while rounds > player_point or cpu_point:...
Forum: Python Nov 5th, 2009
Replies: 5
Views: 451
Posted By snippsat
Yes good.
Or shorter.
a = [raw_input('>')for x in range(5)]
Forum: Python Nov 5th, 2009
Replies: 5
Views: 451
Posted By snippsat
A for loop is easier for this.


for i in range(4):
for item in ['a,b,c,d']:
item = raw_input("something: ")

something: 7
something: 8
something: 9
Forum: Python Nov 4th, 2009
Replies: 7
Views: 273
Posted By snippsat
Next time if you post here try to post some code.
That will show that you but some effort in to it.

With homework we will not just post finish code.

Here is one soultion,as extra i put number...
Forum: Python Nov 3rd, 2009
Replies: 7
Views: 273
Posted By snippsat
One more,now start to think how to put this together.

>>> count = 0
>>> a = 55
>>> if a % 2 == 1:
count += 1
print 'odd', count

else:
print 'even'
Forum: Python Nov 3rd, 2009
Replies: 7
Views: 273
Posted By snippsat
You should try to post some code yourself.

Can give you some tips.
>>> for i in range(0,7):
a = random.randint(0,100)
print a

79
21
69
Forum: Python Nov 3rd, 2009
Replies: 14
Solved: palindrome
Views: 476
Posted By snippsat
>>> def is_palindrome(s):
... return s.lower() == s[::-1].lower()
...
>>> is_palindrome('test')
False
>>> is_palindrome('racecar')
True
>>> is_palindrome('RACECAR')
True
Forum: Python Nov 1st, 2009
Replies: 2
Views: 187
Posted By snippsat
Lets break it down.

IDLE 2.6.2
>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in a:
print i

Mary
had
a
Forum: Python Oct 31st, 2009
Replies: 8
Views: 530
Posted By snippsat
Du you mean the Attached Thumbnails?
Thats just screenshot capture with free program jing.
http://www.jingproject.com/
Forum: Python Oct 30th, 2009
Replies: 6
Solved: Using Functions
Views: 273
Posted By snippsat
Doc string and help is ok to know about to.
>>> l = []
>>> type(l)
<type 'list'>
>>> dir(l)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__',...
Forum: Python Oct 30th, 2009
Replies: 6
Solved: Using Functions
Views: 273
Posted By snippsat
Think maybe you are confused about calling a function and calling a method.

def my_func(name, greeting = 'Hello'):
print '%s, %s' % (greeting, name)

#Call a function
my_func('tom') ...
Forum: Python Oct 29th, 2009
Replies: 7
Views: 307
Posted By snippsat
Always use 4 space for indent.
Read PEP 8.
http://www.python.org/dev/peps/pep-0008/

Tutorial look like it come from sthurlow
http://www.sthurlow.com/python/lesson05/

And some strange code...
Forum: Python Oct 29th, 2009
Replies: 2
Views: 240
Posted By snippsat
PyQt support python 3.x
http://www.riverbankcomputing.co.uk/software/pyqt/intro

This post has many PyQt example.
http://www.daniweb.com/forums/thread191210.html
There are also example of new...
Forum: Python Oct 29th, 2009
Replies: 7
Views: 307
Posted By snippsat
Or if you stay with raw_input,you can convert to integer later in the function.
def add(a,b):
print a, '+', b, '=', int(a) + int(b)
#print '%s + %s = %d ' % (a, b, int(a)+int(b)) #...
Forum: Python Oct 28th, 2009
Replies: 6
Views: 315
Posted By snippsat
Look like cx-freeze has come out with a version for python 3.
http://cx-freeze.sourceforge.net/

Or just use python 2.x and python 3., there is no point just to use python 3.x for now.

I will...
Forum: Python Oct 28th, 2009
Replies: 8
Views: 530
Posted By snippsat
Hi here are som changes.
Done some work on this,i was thinking making somthing simelar as this for fun.
So helping you a little is no problem,set my self as co-developer in about box if you dont...
Showing results 1 to 40 of 78

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC