Forum: Python 1 Day Ago |
| Replies: 6 Views: 115 I think that this may simply be the same thing using different logic:
user_input = [ 1, 2, 3 ] #all are integers
int_data = [ 1, 2, 3, 4, 5 ] #all are integers
for num in user_input:
if num... |
Forum: Python 1 Day Ago |
| Replies: 6 Views: 115 Here's some examples of converting between strings, lists, lists of strings, and ints using list, str and int:
>>> usr_inp = '123456'
>>> usr_inp2 = '1,2,3,4,5,6'
>>> list(usr_inp)
['1', '2',... |
Forum: Python 2 Days Ago |
| Replies: 9 Views: 166 If you declared the encoding (http://www.python.org/dev/peps/pep-0263/) at the beginning of your program the same way that IDLE does, it would have worked I believe? |
Forum: Python 2 Days Ago |
| Replies: 9 Views: 166 Try this trick (I'm assuming you're using Windows)
1) Open up a terminal (command prompt window) Ctrl+R -> cmd -> [Enter]
2) Type/find path to Python executable dir C:\Py* -> [Enter]
# You... |
Forum: Python 2 Days Ago |
| Replies: 5 Views: 157 And if that's not an option make sure you're both installing and running all these things by right-clicking the executable and selecting "Run as Administrator" |
Forum: Python 2 Days Ago |
| Replies: 7 Views: 147 We can't really do your homework for you, but the basics of a while loop are like this.
some_flag = initial_state
while some_flag (does not meet) my_condition:
perform action
update... |
Forum: Python 2 Days Ago |
| Replies: 4 Views: 111 Just please note that in Python, we use the built-in function dict() to convert certain objects to a dictionary. If you used the above code, you would lose this ability as you're overwriting that... |
Forum: Python 2 Days Ago |
| Replies: 9 Views: 166 He also is using parenthesis in his print statements. I'd surmise that he's using Python 3.0, in which case the use of input is the only option. (input has been replaced by raw_input)
EDIT:... |
Forum: Python 2 Days Ago |
| Replies: 2 Views: 112 def main():
print "This program illustrates a chaotic function."
print "Please enter two numbers between 0 and 1."
x = input ("Enter first number: ")
y = input ("Enter second... |
Forum: Python 2 Days Ago |
| Replies: 1 Views: 88 So each record is 4 lines total (with only 3 lines we care about).
Can you give an small snippet of a file with at least two records for example? I envision either simply taking every 4 lines and... |
Forum: Python 2 Days Ago |
| Replies: 8 Views: 144 Why not use one that does then?
I use Notepad++, but I know that even python-specific IDEs like PyScripter have parenthesis highlighting, etc. In fact, PyScripter will have a red underline on any... |
Forum: Python 3 Days Ago |
| Replies: 14 Views: 270 Use replace to swap out the punctuation for an empty string (''). Then use upper on both the original and the reversed string when you compare them so that the cases are the same. |
Forum: Python 4 Days Ago |
| Replies: 5 Views: 198 Your real problem is that you're using IDLE.
Your best bet is to switch to a better-featured (not to mention better-designed) IDE and run your scripts directly using python.exe or pythonw.exe
I... |
Forum: Python 10 Days Ago |
| Replies: 5 Views: 346 We're not here to do your homework for you. But good job on copy-pasting your assignment.
Dear MasterofPuppets,
You shouldn't be spoon feeding people looking for us to do their homework for... |
Forum: Python 11 Days Ago |
| Replies: 8 Views: 319 How about instead of just generating an arbitrary StaticText object, assign it to a persistent member of your class (let's call it self.login_status_text). Then instead of generating it each time,... |
Forum: Python 11 Days Ago |
| Replies: 17 Views: 381 Okay, you've solved your own problem you just don't even realize it yet. The circle function is looking for the values you suggested above. Everything you've provided is correct except the... |
Forum: Python 12 Days Ago |
| Replies: 17 Views: 381 |
Forum: Python 12 Days Ago |
| Replies: 7 Views: 284 The same way you create any .exe, using py2exe (http://www.py2exe.org/)! Search this forum for examples of setting up a setup file. |
Forum: Python 12 Days Ago |
| Replies: 1 Views: 126 If you're looking for native-looking windows apps you'll want to go with wxPython. This is a Python class wrapper for the wx.widgets toolkit, which is cross-platform and extremely powerful.
... |
Forum: Python 12 Days Ago |
| Replies: 17 Views: 381 So if getpos() is a function for a class object, then you forgot the most important detail. The parameter self!
Your function should be defined as such:
def getpos(self):
r1 = x,y =... |
Forum: Python 12 Days Ago |
| Replies: 2 Views: 199 It will be way simpler to use string formatting like so:
>>> print '%04X' % 16
0010
>>> print '%04X' % 245
00F5
>>> print '%04X' % 1024
0400
>>> print '%04X' % 4096
1000 |
Forum: Python 12 Days Ago |
| Replies: 2 Views: 239 You've simply forgotten to put the value of results into the string. Instead you mistakenly typed the name results. Here's how you should use string formatting to add the value:
... |
Forum: Python 14 Days Ago |
| Replies: 2 Views: 138 In the if statement you are using w[i+5].
This means that you need to make sure the maximum i plus 5 does not go out of bounds for the string. Let me demonstrate:
>>> w = 'aabbccdd'
>>> print... |
Forum: Python 14 Days Ago |
| Replies: 12 Views: 307 |
Forum: Python 14 Days Ago |
| Replies: 4 Views: 167 Basically you have to iterate over your "split" coefficients and then perform float conversion on each one independently. When you split them they return a list, which you'll be doing your iteration... |
Forum: Python 14 Days Ago |
| Replies: 6 Views: 263 Why yes, that is poorly coded. Good thing this is Python!
>>> x != 1 and x != 2 and x != 3
True
>>> x not in [1,2,3]
True
Data validation is extremely important for code that is... |
Forum: Python 14 Days Ago |
| Replies: 12 Views: 307 The best beginner's language is Assembly code. It will teach you how amazingly convenient a high level language like Python is.
That is sarcasm, but just read my response to this post in the... |
Forum: Python 14 Days Ago |
| Replies: 1 Views: 263 This (http://docs.python.org/library/cgi.html#installing-your-cgi-script-on-a-unix-system) should help. Don't ever underestimate the power of documentation. |
Forum: C++ 14 Days Ago |
| Replies: 6 Views: 212 I don't see any reason why you should skip your high school's C++ classes; however realize that your high school career doesn't really impact your job opportunities as much as your college career.
... |
Forum: Python 14 Days Ago |
| Replies: 9 Views: 288 This code has a lot of room for improvement. It would benefit you to read up on classes (http://docs.python.org/tutorial/classes.html)and functions... |
Forum: Python 14 Days Ago |
| Replies: 6 Views: 250 Can you explain what the bug is? Each call worked and printed "This is Test2's method."
What was the expected output?
EDIT: I think I understand now. You're saying the real program that you... |
Forum: Python 15 Days Ago |
| Replies: 10 Views: 335 Unless you run your script on a compatible platform, you will not be able to experience the joy of curses, no. If you're on windows you can either download and burn a linux live CD to boot from... |
Forum: Python 15 Days Ago |
| Replies: 1 Views: 121 You'll find it all here (http://www.pygame.org/news.html). Download pygame, tutorials, code examples, everything.
there's also a number of threads about pygame in this very forum. Just search... |
Forum: Python 15 Days Ago |
| Replies: 10 Views: 335 The platform can be simplified to mean your operating system. If you load up a python interpreter try the following exercise:
>>> import sys
>>> sys.platform
'win32'
>>> import curses... |
Forum: Python 15 Days Ago |
| Replies: 7 Views: 263 You're not an idiot, you're learning! It's good that you've solved your own problem. I actually just read an article about how a programming instructor put a teddy bear on his desk.
When... |
Forum: Python 16 Days Ago |
| Replies: 4 Views: 232 |
Forum: Python 16 Days Ago |
| Replies: 4 Views: 303 Gribouillis
I'm not sure if this has been fixed or not (perhaps you're using a newer version of Python where this bug has been eliminated) but when I use your path.join this is what I get:
>>>... |
Forum: Python 16 Days Ago |
| Replies: 4 Views: 232 You're likely getting an exception. When an exception is raised, the program quits.
The best way to catch the traceback is to open your own command prompt and run the program that way.
Go to... |
Forum: Python 16 Days Ago |
| Replies: 10 Views: 335 That's because curses isn't available for Windows. The documentation should probably specifically say that, but they actually just tip-toe around that fact:[Source = PyDocs... |
Forum: Python 16 Days Ago |
| Replies: 2 Views: 196 It would be easier for us to help if you gave us just the barebones code that produces this abnormality. Most users won't have every single one of those modules and it would be cumbersome to... |