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...
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...
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...
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...
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 *...
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?
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...
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...
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...
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...
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...
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.)
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
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...
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...
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...
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...
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"...
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...
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:~$...
[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)...
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()...
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
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 =...
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...
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...
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 -...
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...
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.
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...
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...
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...
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...
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...
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?
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
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...
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...
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...
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...
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...
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: