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. BiGyElLoWhAt

    Python Debugging the Swarzchild Metric - ValueError

    I'm messing around with the swarzchild metric, and I keep getting errors. First, it was a memory, which I could have guessed, 10000x10000 array, so I lowered it to 1000x1000 and it moves past that point, now. However, this is where I'm getting my error: Gravity = zeros([1000,1000]) while i <...
  2. S

    Python Why is my Hydrodynamics Simulation Code Producing a Noisy Signal?

    Hi! I have this code which should simulate a sod shock tube like this: https://en.wikipedia.org/wiki/Sod_shock_tube But when i plot density versus distance I just get something like a noisy signal. Any idea where I am doing something wrong? from matplotlib import pyplot as plt import numpy as...
  3. fluidistic

    Python MITx edx 6.00.2x python 2 code, need to fix a bug

    Hi people, I've "enrolled" into the edx MITx 6.00.2x course on python and data science, but I don't plan to get a certificate and I started so late that all the problems I'm facing aren't due anymore so I think this gives me the right to seek help here. Basically the task is to simulate some...
  4. DiracPool

    Python Problems installing Python modules

    I've installed Python 3.5.1 successfully, and I've downloaded add-on modules such as numpy, scipy, matplotlib, etc, but when I try to import them into python I get the following: "ImportError: No module named 'numpy'", etc. There's no executable file in the numpy download to activate anything...
  5. S

    Python Fit blackbody spectrum to data in python

    Hi! I have to fit a blackbody spectrum to some data points. The y-axis is in mJy and the x-axis is in log_10(freq). My code looks like this: from __future__ import division import matplotlib.pyplot as plt import numpy as np from scipy.optimize import curve_fit h = 6.63*10**(-34) c =...
  6. BiGyElLoWhAt

    Python Solve Lambda Error in Python Homework

    Homework Statement Somewhat irrelevant, but we need to simulate the redshift for a star system. Pretty open ended. Single star, binary, whatever. The problem is this: TypeError: <lambda>() takes at most 1 argument (5 given) And upon searching, most people who get this error have a function that...
  7. DiracPool

    MATLAB Learning Matlab & Python for a DARPA Grant

    I'd appreciate it if someone can give me a little guidance here. I'm slated to be entering a Ph.D. program in the fall where I'll be working on a machine intelligence project under a DARPA grant designed to create autonomous rovers. They want me because of my background in understanding the...
  8. BubblesAreUs

    Python Python problem: Plotting two functions against each other

    Homework Statement Enter a minimum height and velocity into plot function and return a velocity-height plot. Homework EquationsThe Attempt at a Solution # Find length of general list n = len(K) # Build a list for time [0,20] seconds ( Global) time = n*[0.0] # Acceleration of gravity g =...
  9. J

    Python Making a pretty n-body simulation

    Hi all, I have recently created an nbody simulation in Vpython for a few thousand particles where each particle is about 4000 times the mass of our Sun. Vpython is doing exactly what I want it to do the only problem being the output is extremely low quality (black spheres on a white...
  10. C

    Translate change of length to force in hanging chain problem

    I'm trying to write a simple script in blender python in order to show load deflection in cloth simulation. My question is: Is it possible to translate the change of length (distance between two nodes), into a force? (Newton between those nodes)? In addition you will find a minimal example. The...
  11. A

    Python Monte Carlo error calculation PYTHON

    I am using the monte carlo method to calculate the integral of cos^2(x). This is done using N random numbers. In my case I am doing it for 10^i random numbers when i ranges from 1-6. I want to calculate the error on the integral for each value of i used. I know for each value of N I want to...
  12. N

    Python How can I control FLIR camera (tau 2.4) by using Python?

    Dear Forum, I am trying to use Python to control FLIR camera (tau 2.4) but I do not know there is possible or not? I say that because I see when I connect IR camera to the computer using USB, it shows COM port in the Device Manager and I've seen python possible to work with COM port through...
  13. Pavkazz

    Python Help with Python computation to calculate age of universe

    Homework Statement I'm using python to calculate the age of the universe, by working out the distmodulus for a set of galaxys (using the V and I bands) then working out the distance in parsecs and then hubbles constant etc... I keep getting values that are 10s of magnitudes out which I assume...
  14. BiGyElLoWhAt

    Why is the duration an integer and why am I not getting any output?

    Homework Statement A rocket can either fire or not fire for a duration of 1-100ms with equal probability of firing/not firing. Determine how far it will go in the first 2 seconds of flight. Homework EquationsThe Attempt at a Solution # -*- coding: utf-8 -*- """ Spyder Editor This is a...
  15. S

    Python Are errors important in calculating integrals in Python?

    I am reading Mark Newman's Computational Physics textbook. He goes over calculating integrals with Simpsons's Rule and the Trapezoidal Rule, and then he goes over calculating their errors. Why would I have to ever worry about the error of the integral? He has the chapters online at his website...
  16. C

    Java What are the key differences between Python and Java?

    Hello all, If this has been asked before, please forgive me; what can Python be used for? Is it good for programming apps and whatnot? I have never done any programming before, so this is my very first programming language that I have just started learning. Thanks for answering
  17. T

    Python Improving Fourier Transform Visualization in Python

    Hello, My name is Thibaut. I am looking to improve my code in python in order to have a better look a my Fourier transform. as you can see on the image, we barely see any detail of the peaks on the image. Also it's not centred. the zero order peak in on the corner, not in the centre. Any idea...
  18. J

    Python Trying to learn Python; is this book incorrect?

    I had a brief stint with Python a year or two ago, and after I learned of the Raspberry Pi I knew I should try to learn again. I purchased this book, knowing full well that the online resources would be sufficient, and some of the code doesn't seem to work. hello_str = "Hello World"...
  19. Ryaners

    Python Using Python to calculate projectile motion with resistance

    I'm trying to write a program to calculate the trajectory of a projectile with air resistance. I've made the following function which calculates the position of the particle based on a given launch angle and initial velocity: def traj_fr(angle, v0): #function that computes...
  20. Mastermind01

    What should I do next after completing an introductory programming course?

    Hello, So I'm in high school and I wanted to self-study programming. In summer I completed the course Introduction to Computer Science and Programming Using Python on edX . I really liked it. I was wondering what I should do next and from where? Should I learn a different language (C , C++ and...
  21. C

    Python Writing Binary Files in Python 3.x

    Hi, I've been trying to write a simple binary file in Python 3 and have not yet been able to find a clear answer / solution online. Could you please suggest a simple way to read / write binary files in Python 3? My Code: # Create Binary File def dec_base(k,b=2): """ Default base is 2...
  22. L

    Python Non-linear elliptic differential equation - python

    Hey guys, I'm going to be honest and say I'm so stuck on this assignment - I really need help! I've took on a third year computational physics course last year - turn your weaknesses into strengths someone told me. Well, I failed and I'm back doing it again this year! So, I just have to pass...
  23. W

    Python Help designing an n-body gravity simulator in Python

    Hi everyone: I wanted to design a 2-dimensional gravity simulator as part of a larger research project. I wrote it in Python using numpy to store positions, velocities, and accelerations, and matplotlib to display the trajectories; code is available upon request. In order to solve the problem...
  24. Mark44

    Python Simple Python Debugging with Pdb: Part 2 - Comments

    Mark44 submitted a new PF Insights post Simple Python Debugging with Pdb: Part 2 Continue reading the Original PF Insights Post.
  25. H

    Python Beginning Python, cf dedicated calculator package

    I am no programmer but I want to learn for personal development. so physicsy type guys recommended Python. I downloaded it and have been playing. my goals for programming are three; 1. learn to code just for fun 2. do calculations and numerical calculations 3. input data from transducers...
  26. Mark44

    Python Simple Python Debugging with Pdb - Part 1 - Comments

    Mark44 submitted a new PF Insights post Simple Python Debugging with Pdb: Part 1 Continue reading the Original PF Insights Post.
  27. I

    Python Solving 3D Geometry Problems with Python

    Homework Statement Requirements: http://i.imgur.com/2WKyhto.png Homework Equations 2(L * W + L * H + W * H) SA = (2 * pi * radius * height + 2 * pi * radius^2) height = (volume)/(pi * radius^2) The Attempt at a Solution Code link: http://pastebin.com/sKFEGN0C
  28. Mr Davis 97

    Python Implementing some pseudocode in python

    I need to implement the following pseudocode in Python: N=5 #where N is number of years For (rate = 0.05, rate <= 0.15, rate = rate + 0.05) For (principal=10000, principal <=15000, principal=principal+1000) simple = principal * (1 + rate * N) #where N is number...
  29. H

    Python Python 2.7 on Windows installation for Astronomy

    Hello people i know this program is better to use on Linux, but for personal reasons i can't change to Linux OS. So I'm having a little problema on how to use python and install the modules of astropy, ipython, I've already installed pip but i have a error on python shell that says: Error...
  30. F

    Python How can I input a polynomial equation of infinite terms in P

    I have been given a task to create an interpolating/extrapolating programme. I have completed the programme for linear interpolation (2 points) but now must make it usable for 3 or more points, ie a polynomial of n points. I think I have the equation in general for a polynomial as it is an...
  31. BluberryPi

    Python Python vs Ruby: Which is Better?

    Hello! BlueberryPi here, and I have got a question for you: is Python better than Ruby? Background Info: Python is a strong programming language which allows GUI's to be built without much pain. It built sites like Google, You Tube, Pinterest, and DropBox. Ruby is a flexible language which...
  32. Mr Davis 97

    Java Why is type casting different in Java and Python?

    I am writing code in both Java and Python, and am a little confused about one thing: casting. In Python, we cast data types by using int(), str(), float(), etc. These are functions which convert one data type to its representation as another data type. However, in Java, it doesn't work like...
  33. E

    Python What are the good books for physics and python?

    What would be the good books on how to use Python (or any other language other than MatLab) and its capabilities on numerical physics?
  34. Mr Davis 97

    Python How to Convert Python Code to Effective Pseudocode?

    I have the following python code: I need to know how to best convert this to pseudocode. On one hand, I am afraid of making it too python specific, and on the other hand, it can't be too general. For example, for the 2nd and 3rd blocks of code, how would I write them in pseudocode? What...
  35. estv

    Python Interactive Website to Learn Python for EE Student

    Hi, I'm trying to learn python for electrical engineering application. Is there any interactive website to learn this, especially the one with interactive compiler or result animation? Maybe equipped with microcontroller simulator, LED, and actuator? (if is it possible) So far, I've tried...
  36. dylanreynolds1

    Computational General Relativity

    Hello all, first post. I have come here to get second opinions on the program I have written to compute the Einstein Tensor (the Riemann Tensor and Ricci Tensor). I enjoy looking for solutions to the Einstein Field Equations, however computing them by hand is not realistic. I decided to write a...
  37. E

    Python Simulating Saturn's rings in python

    Hi, I have to write a program in python (for school) that simulates a specific structure. I choosed saturn's rings. I've started by wrinting an N-body code. My goals are explaining the divisions in saturn rings as cassini division. I don't know if it's a great subject. The teacher told us to...
  38. S

    Python Resources for programming math solvers in Python

    Hi, I was just wondering if there were any good resources/sites for learning to plot and solve differential equations and any other math for that matter, specifically in Python? The physics program at ASU is great but we aren't really given any class time to learn how to program, it's all on our...
  39. R

    Simulating noise with Yuler and Burg

    Hi After removing high frequency white noise in my INS sensor, I want to simulate low frequency noise with Burg or Yuler. I used some functions in python to analyse the recorded data and to get parameters to use. But the the problem is the sequences generated diverge (and take very big...
  40. PhotonSSBM

    C/C++ C, C++, or Python for solving Diff. Eq./other math stuff

    I have a friend who wrote a script for doing Runge Kutta and I didn't even know you could do that in Python. He's kind of poor at explaining stuff so I'm here to ask how one learns to do that. I'm a Physics/Comp. Sci. student who's still self teaching myself a lot of stuff. I've only taken an...
  41. Prof. 27

    Python Python DEAP Library -- List index out of range error

    Homework Statement So I'm currently modifying an example Symbolic Regression program that uses genetic programming, a type of evolutionary algorithm. I'm using the python deap library. Not sure if anyone on here is familiar with it, but I think that the error is more general to a misuse of...
  42. N

    Python Project euler 1 understanding the python code

    If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. This is the code for python I found (didn't create) which I believe is correct: max = 1000 result = 0 for...
  43. I

    Python Preparing for University: Maths and Python in 5 Months

    I am applying to University in January 2016 for either maths or computer science. I have taken the Gr. 12 prerequisite courses and did alright in them (calculus 89, physics 96, etc), but I feel I still do not have a solid foundation in maths to really feel comfortable going into a degree...
  44. Hercuflea

    Python [Python] Why does this loop execute 4 times?

    I've written a code which reads in an input file and extracts a number which represents a grid size, from lines in the file which can contain arbitrary characters. The extraction of the data seems to be working, but for some reason the loop executes 4 times and then moves on to the next...
  45. M

    Python Inconsistent values when integrating [Python]

    I have a 2D Gaussian: ## f(x,y) = e^{-[(x-x_o)^2 + (y-y_o)^2]/(2*{sigma}^2)}## which I converted into polar coordinates and got: ## g(r,θ) = e^{-[r^2 + r_o^2 - 2*r*r_o(cos(θ)cos(θ_o) + sin(θ)sin(θ_o))]/({2*{sigma}^2})} ## The proof for how this was done is in the attached file, and it would...
  46. C

    Python How much faster is Python than Mathematica?

    I've been running some of my own simulations of a variation on a standard map using Verlet integration on Mathematica, and I would like to start generating maps of phase space using ~25,000 initial points. I'm currently at 1000 points using Mathematica, and each simulation takes about 15 minutes...
  47. M

    Python Python: Generating a list and then matching question

    This seems like a fairly common technique but I'm fairly new to programming and don't quite know what the proper terms to find such an algorithm would be. In my case, it seems like a list of all possible values would approach almost a billion, and I feel like there's a quicker approach to...
  48. E

    Python Python 2.7: Fit a model to data

    Hi, I'm trying to get how well a known function fits to a set of data. I'm not interested in the data's line of best fit or anything, I just want to know how close it is to my model. I've tried using curve_fit and linregress but neither really give me what I'm after. My data follows a...
  49. M

    Python Python: Integrating a function but getting large errors

    My code: import numpy as np import matplotlib.pylab as plt import math import random from scipy import integrate R1 = .001 R2 = 7 def G(r,theta): sigma = random.randint(4000., 7000.)/1000. # width of beam is 4 - 7mm r0 = random.randint(0, R1*1000.)/1000. #random centroid theta0 =...
Back
Top