Python Definition and 661 Threads

PYTHON was a Cold War contingency plan of the British Government for the continuity of government in the event of nuclear war.

View More On Wikipedia.org
  1. C

    Python Uniform Circular Motion - python program

    Hello guys. I am taking an introductory course in computer programming. For one assignment I was to make up a word problem, then write a program to solve it. I wrote a program to calculate the radius of a circular orbit based on the orbiting object's current velocity, and other parameters. Can...
  2. J

    Python How do I implement a 1D linear convection using finite differences in Python?

    Hi, I have a pseudocode I would like to try and implement and understand the programming of it in python. The physics and maths of the case is no problem, but the implementation of the code in Python is something I'm not familiar with. The problem is a simple 1D linear convection using...
  3. B

    Python Write an is_prime function in Python

    Homework Statement Write a function, is_prime, which takes a single integral argument and returns True when the argument is a prime number and False otherwise. Add doctests to your function as you develop it. 2. The attempt at a solution def is_prime(n): x = 1 while x<=n...
  4. R

    C/C++ Recommend books on Python/ C++ Programming

    idk if some of you remember Recommend a book on Python Programming thread i created a while back. As some of you suggested, i bought Lutz's book. I've looked into (or at least skimmed through) most of the book...i really liked it. I'm currently working on GUI Tkinter, it seems interesting...
  5. B

    Python Why Can't I Draw Multiple Houses in Python?

    Basically, I have a function that draws a house. You enter (x, y) coordinates to pick where the house is drawn. However, it only let's me draw one house. Why can't I draw more then one house by calling the draw_house(x, y) function multiple times? Here's the code: from gasp import *...
  6. T

    Python Basic python stuff in 1st/2nd year physics)

    I have never done any programming (except very basic python stuff in 1st/2nd year physics), and I want to learn some a bit more in depth over the summer. Can anyone recommend which programming language I should learn? What's most-widely used for physics/astrophysics?
  7. D

    Python Python: Converting float into a 'time'

    Hello. Right now I've got two floats that represent times. say 9.5 for 9:30 and 16.5 for 4:30. Basically I want to compare these to the current time, which right now I am doing by saying dt=datetime.now() while 9.5 < float(dt.strftime('%H')) + float(dt.strftime('%M')/60) < 16.5...
  8. D

    Python How to Compare Times in Python Using the Time Library - Step by Step Guide

    Currently I have a program in which I want to compare times. I have dt = datetime.now() x = dt.time() which gives me the current time in Hours:Minutes:Seconds:MicroSeconds. I also have variables HourStart, MinuteStart, HourEnd,MinuteEnd. Which are the hours and minutes that are the...
  9. D

    Python Writing out to a directory in python

    Hi, I have a program which is reading in line by line information, saving that, and writing it out to a file. How do I change where the files are created? Also, can I create a folder to write the files out to in my program? The second issue I have is this. right now my program opens the...
  10. R

    Python Recommend a book on Python Programming

    I'm not a complete newbie to Python but I'm not a pro either (far from it). I played with Python on surface, like doing simple computation in python shell or creating a very simple program (such as finding roots of quadratic equations). Anyway, i would like to explore more into this subject...
  11. M

    Python Stuck on Continue Statement: Solving a Python Coding Problem

    I Have been using A Byte of Python, and I am now stuck on the Continue Statement. Here is my code. #!/usr/bin/python #Filename: continue1.py while True: s = input('Enter something : ') if s == 'quit': break if len(s) < 3: print('Too Small') continue print('Input is of...
  12. F

    Python Exploring Python SciPy: Free Libs for GUI, Signal Processing, and More

    I'm going to mess around with some Python and was wondering what free libs I should consider. So far I've got: GUI - Tkinter Scientific (mostly signal processing for me) - SciPy Are these OK? Any opinions? Other libs you like (gaming, sound, hardware control & networking, etc.)
  13. R

    Python Python text in each grid in a grid field

    Hey iam trying to place some text in each grid in a grid field and also to fill each one with different color can anyone please help me out...
  14. T

    Python Python Plots Book: Best Examples & Guide

    Hi there, I'm looking for a good book dealing with all the power of python plots (3D plots, basemap-plots, mayavi ...) and with good code examples. Any recommendations? Thanks
  15. D

    Python Python Programming Basics: IDLE vs Command Line

    I just started learning programming and am a little confused about the difference between IDLE and the "Commands Line." What's the difference?
  16. S

    Python Learning Python Programming - Advice for Beginners

    I am new to computer programming, but if anyone familiar with Python has any suggestions or resources for a beginner, I would appreciate it. How useful is programming in Python? How does it compare to other programming languages? I've also heard that Python is relatively simple to learn...
  17. J

    Python Python: How does the return statement work?

    Homework Statement I am trying to write a program in which I have a function that uses the variable x. For example, def function(x): x=x+2 return x function(4) Now I want to print out what x was inside the function. I thought I would just say "print function(4)", but...
  18. W

    MATLAB Compile Python, Matlab and Python

    1) I know that python is an interpreted language. But is there a way to compile to code to make it process faster? 2) Suppose I have a huge array of data. I want to process it. If I were to run the process through python(with numpy and scipy), Matlab, and Mathematica which one would be able...
  19. daniel_i_l

    Python Python Forking: Why Wait for User Input?

    For some reasons, if I fork a process (or start a thread) in python and let the original program wait for user input, the the forked process doesn't print anything to the screen until the newline character is printed. For example (i used '----' instead of indent): doesn't print any thing to...
  20. G

    Python Help with Python RK4: Solving Error Plotting 1st Order ODE

    i have been attempting to plot a first order ODE with pyhton's rk4 i can't display the graph and i have been having this error: Traceback (most recent call last): File "C:\Documents and Settings\AP155user38\Desktop\gladys python codes\differential equations and runge-kutta\1ODE.py"...
  21. W

    C/C++ Learning Python & C++: Is It Easy?

    I am learning Python right now and it is pretty cool. Just out of curiosity, would it be a easy transition to learn C++ after I master Python?
  22. W

    Python Exploring Computational Physics with Python

    Hello, I have recently become interested in computational physics. I know a good deal of Mathematica. Recently I have heard great things about Python. My questions are: 1) How useful is Python in computation? 2) Would there be a better program to learn instead of Python for computation? Any...
  23. G

    Python Fixing Vim Macros for Python in .exrc File

    Hi, I am trying set a macro in vim's .exrc file such that when I type # in normal mode, vim will call python3 to run my code. I edited the first line of the .exrc file (which is all i need to do i believe), however when i try to open my .py code in vim I get this message: ubuntu@ubuntu:~$...
  24. M

    Python Python, RungeKutta and first-order differential equation system.

    [b] Homework Equations The equation is, given to me by lurflurf,: mv' + f(v ) + s(u) = F(t), t > 0, u(0) = U0, v (0) = V0 where v=u' For the record the equation was: mu'' + f(u' ) + s(u) = F(t), t > 0, u(0) = U0, u' (0) = V0 . The Attempt at a Solution def rhs(u, t)...
  25. M

    Python Python: open dat-files, read data

    Homework Statement I have two programs and neither works. In the first program I don't get any autput from andre(f): f = open("densities.dat", "r") def andre(f): densities = {} for line in f: density = float(line[12:]) name = line[0:10].strip()...
  26. M

    Python Python, making a float of a list

    I have made a list of data from a file, the file contains numbers and I want to calculate with the numbers. How do I make a float of a list where a[1] is: ['0.00500006128645'], I tried to just use float, but then I got: float() argument must be a string or a number
  27. J

    Python My Python is not working like I need it to

    This is what I have, and for some reason it won't move...I trust all you smart people could point me in the right direction...thanks from visual import * from visual.graph import * relaxedlength = vector(.60,0,0) # length of spring when it isn't stretched or compressed spring =...
  28. M

    Python Making an arrey of a zipped list, Python

    How do you make an arrey out of this list? for X, H in zip(xarrey,harrey): print "%.2f %.5f" % (X,H)
  29. M

    Python Run Python on Windows: A Beginner's Guide

    How do you use Python on Windows? I have Python 2.5.1, but have only tried Python on the school's computers where they use Linux.
  30. M

    Python Python: How to get my variables out of a function

    Homework Statement The exercise: Make a Python function for computing g(t) = e**(-a * t**2) and gderiv(t) = -2*a*t*g(t) Return the function values of g(t) and gderiv(t). Apply the function to write out a result in the format: g(1, a=0.5)=0.606531, g’(1, a=0.5)=-0.606531 I have made a...
  31. M

    Python Nasa, Ares and the gratuitous Monty Python joke

    Nasa is facing more problems with it's Shuttle replacement. following Ares-I being too small to lift anything the Ares-V looks like it is too heavy for the road to the launchpad. http://www.flightglobal.com/articles/2008/08/21/314931/nasa-faces-budget-busting-crawlerway-rebuild-for-ares-v.html...
  32. O

    Python Solve Python Woes: How to Get a Five Digit Number Input in One Try

    python woes: ~/code/python$ cat five.py #!/usr/bin/env python x = input('Enter a five digit number: ') while (not(x < 10000 and x > 99999)): x = input('Five digits please: ') firstDigit = x / 10000 secondDigit = (x / 1000) % 10 thirdDigit = (x / 100) % 10 fourthDigit =...
  33. F

    C/C++ Creating Hotkeys with GTK and Python (or C/C++)

    Has anyone used GTK and Python (or C/C++) here? Any ideas on how to make keyboard hotkeys? I am using Glade3 to build the GUI. Thanks in advance
  34. R

    Python Understanding Caching in Python Fibonacci Series

    Hey, I decided to start learning python so I downloaded it yesterday and decided to try and make a simple program to produce the Fibonacci series. I managed to do it using a function similar to that on wikibooks: def fib(n): if n < 2: return n else: return fib(n -...
  35. O

    Python Python Book Error: Solving a Math Problem with Aliens and Multiple Heads

    In python for the absolute beginner, we have this (page 28): "If an alien has 3 heads, grows 1 more than double his total number of heads, how many heads does the alien have?" My formula is: (3 * 2) + 1 (For example, in this sequence, each sequential number is one more than...
  36. O

    C/C++ Can you append digits to a variable in c++ or python

    Say you have a variable x, that is of type int. x = 1; I just want to create a while or for loop so that each time it runs it adds another digit to it, such as: 12 123 1234 or 1, 11, 111, 1111, and so on.
  37. S

    Python Help in Python for Computational Physics

    Hi, I am in a computational physics class and we are programming projectile motion in python. I do not know why I am having such a hard time at this, but I cannot get my programs to work. Homework Statement Calculate the effect of backspin on a fastball. How much does an angular velocity of...
  38. S

    Python How to Load a .py File in the Python Interactive Shell for Debugging?

    How can I load a .py file in the python interactive shell for debugging?
  39. T

    Python Programming the error function (erf) in Python

    I'm having very unusual problems posting in the math forum. I am trying to write a program that would calculate phi, the CDF of the standard normal curve, in Python. I tried calculating the erf using a series to do it, as described by Wikipedia. But mine diverges, when it should approach 1...
  40. A

    Python Project in Python: Cop Chase Simulation

    Hi, I'm planning on doing a college project in the Python programming language. I have only started learning it. The project is a simulation of a Cop Chase. The human player controls the getaway car, while the cops are controlled by the computer using strategy written in the program(something...
  41. N

    Java Comparing Python and Java: Performance & Standard Libs

    Any one have any opinions on the differences between these two language (and their closeness to C)... chroot posted about python being almost as complete as java interms of standard libs. I attended a presentation which seemed to verify that claim though you have to download some of the added...
  42. C

    Python Creating and Manipulating Variables in Python for Summation

    I want to write a program like this. It asks for a number, n. It then creates n variables, for example variable_1, variable_2 ... variable_n. Then, after some more input, values are given to these variables. I want to do this because at the end of the program, I want to my program to find the...
  43. C

    Python BitTorrent implemented in Python.

    After endless searching I have resorted to a post, I cannot seem to find anywhere why BitTorrent was first implemented in python, rather than C, Java etc?
  44. Schrodinger's Dog

    Python Monty Python's Life of Brian: The Musical - Not The Messiah

    Ok since I know there are a few fans of Monty Python here, I read today after the success of Sir Spamalot, the musical version of the Holy Grail they've decided to do a musical version of the life of Brian, any thoughts?:smile: http://enjoyment.independent.co.uk/theatre/news/article2271652.ece
  45. F

    Python Is Python the Best Language for Electrical Engineering Students?

    Im in my last year of high school and for about two years now I've wanted to learn to program, but i havnt really gotten into it. Basically I am going to study electrical engineering in a bit over a year (military service comes first) and I would like to learn a language that is useful for...
  46. mbrmbrg

    Python Monty Python and the Holy Grail

    I willingly set myself up for scorn and ridicule. I just watched Monty Python and the Holy Grail, and I just don't get it. Yeah, I laughed a bunch of times, and enjoyed the funny bits in every scene, but all in all... Huh?:confused: Was there supposed to be anything pulling this together, or was...
  47. N

    Python What is the difference between using parentheses and square brackets in Python?

    Hopefully someone (chroot??) wil be able to answer this simple Python question. I am looking at a code written by someone else and there are those two enigmatic statements one after the other: link0=(0,0,0,0) pathlist=[link0] Ok, besides the obvious question of why not initializing...
  48. N

    Python Loading a file (module) in Python

    I have installed Python in a Windows environment and I want to load files to execute them in Python. I have tried "import testprogram.py" and it does load the program and executes it (all the program does is to print something out on the screen) but then there are error messages...
  49. Cincinnatus

    Python Solving Differential Equations with Python and Runga-Kutta

    I'm trying to write a program in python to solve a system of differential equations using the 4th order Runga-Kutta method. I would ideally like the program to be able to solve systems of arbitrary size. To do this, I believe I will need to write a function (rk4) that would take as...
  50. W

    Python Displaying Python on the Internet

    Can someone tell me how you would apply python to a web document. Like add the python code to a geocities.com account? I'd like to know that I can publish Python for all to see :smile:
Back
Top