Forum: Python 3 Days Ago |
| Replies: 10 Views: 268 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 4 Days Ago |
| Replies: 10 Views: 268 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 4 Days Ago |
| Replies: 10 Views: 268 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 5 Days Ago |
| Replies: 14 Views: 341 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 8 Days Ago |
| Replies: 9 Views: 337 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 9 Days Ago |
| Replies: 15 Views: 446 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 9 Days Ago |
| Replies: 15 Views: 446 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 13 Days Ago |
| Replies: 14 Views: 457 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 13 Days Ago |
| Replies: 9 Views: 402 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 13 Days Ago |
| Replies: 14 Views: 457 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 13 Days Ago |
| Replies: 10 Views: 378 >>> import webbrowser
>>> dir(webbrowser)
['BackgroundBrowser', 'BaseBrowser', 'Elinks', 'Error', 'Galeon', 'GenericBrowser', 'Grail', 'Konqueror', 'Mozilla', 'Netscape', 'Opera', 'UnixBrowser',... |
Forum: Python 13 Days Ago |
| Replies: 10 Views: 503 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 18 Days Ago |
| Replies: 5 Views: 274 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 19 Days Ago |
| Replies: 2 Views: 222 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 19 Days Ago |
| Replies: 4 Views: 232 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 21 Days Ago |
| Replies: 9 Views: 311 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 22 Days Ago |
| Replies: 12 Views: 329 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 23 Days Ago |
| Replies: 11 Views: 480 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 23 Days Ago |
| Replies: 12 Views: 329 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 23 Days Ago |
| Replies: 12 Views: 329 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 26 Days Ago |
| Replies: 7 Views: 289 >>> #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 30 Days Ago |
| Replies: 5 Views: 342 Yes good.
Or shorter.
a = [raw_input('>')for x in range(5)] |
Forum: Python 30 Days Ago |
| Replies: 5 Views: 342 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 31 Days Ago |
| Replies: 7 Views: 253 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 32 Days Ago |
| Replies: 7 Views: 253 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 32 Days Ago |
| Replies: 7 Views: 253 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 33 Days Ago |
| Replies: 14 Views: 414 >>> 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: 182 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: 472 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 Views: 241 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 Views: 241 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: 286 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: 228 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: 286 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: 304 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: 472 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... |
Forum: Python Oct 28th, 2009 |
| Replies: 6 Views: 623 >>> import urllib.request, re
>>> from html.parser import HTMLParser
>>> main_page = urllib.request.urlopen("http://www.stats.gov.cn/english/").read(20000).decode('gb2312')
Traceback (most recent... |
Forum: Python Oct 27th, 2009 |
| Replies: 8 Views: 472 You can set size so the text get overwrite.
And som color look better.
try:
self.s.login(self.user,self.passw)
wx.StaticText(self.panel,-1,"Logged in...",pos=(10,200),size =... |
Forum: Python Oct 26th, 2009 |
| Replies: 4 Views: 253 And a shorter version that uses the reverse string metod in a smart way.
>>> def is_palindrome(s):
... return s.lower() == s[::-1].lower()
...
>>> is_palindrome('test')
False
>>>... |
Forum: Python Oct 26th, 2009 |
| Replies: 7 Views: 495 Vegaseat gave you an answer in your own post last time.
http://www.daniweb.com/forums/thread224869.html&highlight=pymailer&page=5
I have used py2exe and wxpython many times it`s works fine.... |