What is Python: Definition and 655 Discussions

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 Strings: Revising & Altering for AI Programming

    I'm revisiting python, because recently our physics department decided to adopt it as our computational language, and I missed the class. I've also been given the impression that it's a very good language for algorithms and what-not. According to...
  2. cpscdave

    [Python] include block of code

    In c I quite often build header files with a bunch of predefined data. Fill it with structures or what not. Then to include that information in my program its a simple #include "myHeader.h" Is there a way I can do this in python? I've created another file "myHeader.py" Have put in some code to...
  3. S

    How can I plot the Voigt Profile function with varying values of a in Python?

    I very new to python and this might look relatively easy to some of you. I need to write a code so that H(a,u) = \frac{a}{\pi} \int_{-\infty}^{\infty} \frac{e^{-y^2}}{a^2+(u-y)^2}dy it plots the above function for different values of the a parameter, so that ultimately i will have a graph of...
  4. D

    [Python] Importing csv files and creating numpy arrays

    So I am fairly new to Python and feel somewhat comfortable with it. I am trying to do something what I think seems kind of simple however am not too experienced with loading files into Python (or any programming language for that matter). What I am trying to do is I have csv files that contain...
  5. A

    Python program to sort negative numbers and even numbers?

    Homework Statement I have to make a program that would end when entered a 0 and print out negative numbers and even numbers separately but what I have so far is not working. The Attempt at a Solution numbers = [] negative_numbers = [] while True: number = input("Enter a number: ")...
  6. B

    Infrared spectroscopy to find water absorption lines

    Hi I am currently trying to find the water absorption lines by using a Michelson interferometer, as a detector I am using an ocean spectrometer. The data obtained is thus the spectrum's "received" by the spectrometer. Am I right to assume that in order to find the absorption peak/peaks I should...
  7. M

    Python, solving Schrodinger equation using Runge-Kutta

    Homework Statement I'm currently working on a project in which I have to solve the energy eigenvalues of the Schrodinger equation to compute the mass of certain Mesons. We've been taught very little programming (so apologies that my understanding is very basic), and are therefore given any...
  8. A

    How to change a two-dimensional array print into normal?

    Homework Statement I made a two-dimensional array program, but now I need some help to alter the program in the print zone. The Attempt at a Solution import sys students = [] grades = [] while True: student = input ("Enter a name: ").replace(" ","") if...
  9. A

    Python: How to show entered input results when entering a 0

    Homework Statement So, I have a program, which I am finishing but I apparently ran into a problem. In the program I have to make that whenever I enter a 0 in the input, the program will stop and print the results. Here's the program before I continue saying anything else: The Attempt at a...
  10. sk1105

    [Python] Custom tick marks in matplotlib

    I've looked around for this and so far haven't found anything close enough to what I'm after. In matplotlib, I want to get a specific tick on the x-axis to label a particular value. I know how to use axvline to get a vertical line marking that point, which is good, and I know how to add...
  11. A

    Python: how to break two times to results

    Homework Statement I need a program, which would break and show results once a 0 is entered in input name and input grade. I figured how to do that in name, but how do I add another break? Like grade !="0"? Homework EquationsThe Attempt at a Solution students = [] grades = [] while True...
  12. A

    Fix Python Print Problem: Get Student Grade Averages

    Homework Statement I made a program that would some up a grade average. Everything seems fine, the only problem, when I run the program at the end it prints out like this: Jack 5 10 6 7.0 Stacy 10 8 9 9.0 Jack 5 10 6 7.0 Stacy 10 8 9 9.0 Jack 5 10 6 7.0 Stacy 10 8 9 9.0 How can I make the...
  13. A

    How to continue this Python program?

    Homework Statement I need a program where the program needs to ask me a name of a student and then a grade. 1) The program needs to end if a 0 is entered. 2) If the name has a number in it, the program should ask the user to enter another name. 3) After the name is correctly entered the program...
  14. A

    Asking a user for a correct input until they give a correct response

    Homework Statement I need a program (in PYTHON), which would ask a user his name and grade, then print them both. 1) If the name has a number it, the program has to ask the same question again until the name is entered correctly 2) The same with the grade. If it's higher than 10, the program...
  15. Avatrin

    Animating wave packet with Python

    Homework Statement So, I start off with initial condition: \psi(x,0) = e^{\frac{-(x-x_0)^2}{4a^2}}e^{ilx} This wavepacket is going to move from x_0 = -5pm towards a potential barrier which is 1 MeV from x = 0 to x = 0.25 pm, and 0 everywhere else. a = 1 pm l = 2 pm-1 Homework Equations I...
  16. A

    Python checking numbers in a given name

    Homework Statement I need to write a Python program, which would: 1) Ask for a name (input function) 2) Keep asking for the name if it is not entered correctly(if it has a digit in it) 3) If the name is entered correctly it will print the name Homework Equations How should I continue the...
  17. P

    What is a Eye Diagram - create it in Python

    I am self learning Python and developing Communication signals concept by coding programs. But I am not sure how to develop Eye Diagram code in Python - cause I do not know the formulas / concept to do so - say I have a signal bits like - 1 1 1 0 0 0 1 1 So what formulas of concept I should...
  18. A

    Help with Python Program: Calculate Student Grades & Averages

    I really need help with a big Python program. Our professor has been MIA for the whole term and now we need to submit a program. I thought I was doing and learning fine on my own, but the program simply does not work for me. I need it till Thursday and I am ripping my hair out because I cannot...
  19. sk1105

    [Python] Why is my syntax invalid?

    global m_mu = 106.0 global M_Z = 91200.0 global a = 1.0/128.0 global theta_w = asin(sqrt(0.23152)) global g_e = sqrt(4*pi*a) global g_Z = g_e/(cos(theta_w)*sin(theta_w)) I have written this code in Python 2.7 using Enthought Canopy, and each line throws up a syntax error, but I have no idea...
  20. S

    Good problems and exercises in C, Python, Ruby and Scala

    I have previously learned C and Python. I'm just starting out with Ruby and Scala. But I need to become more proficient in these languages, so could someone suggest good sources of problems/exercises in each of these languages sources could include websites, books, etc.
  21. NaughtyBear

    Programming Question (Python) - Boolean Binary Search

    So I am in my Intro to CS course and they are going over Binary searches via an algorithm to search for simple things. The code goes as this: Set first to 0 Set last to length-1 Set found to FALSE WHILE (first <= last AND NOT found) Set middle to (first+last)/2 IF...
  22. S

    Fitting an ellipse through 3-d data

    Hey, sorry if this is not the right section to post in, the topic is a bit ambiguous. I've generated a set of coordinate points for the orbit of Mercury (3d cartesian) and now I want to fit an ellipse through it so I can get an accurate estimate of the location of the perihelion. I am using...
  23. Alexi-dono

    [python] How can I get my OS to pick this up as entropy?

    So I am going to be making some keys; and I want to make them more random... So I made this: #I know that the code is pretty crude, but it works. #P.S. it is an infinite loop, run at your own risk import random from random import randint import string import time x=1 n=randint(5,90)...
  24. Venerable R

    Max Distance from which a python detects infrared radiation

    Homework Statement A python can detect thermal radiation with intensity greater than .60 W/m2. A typical human body has a surface area of 1.8 m2, a surface temperature of 30°C, and an emissivity e=0.97 at infrared wavelengths. What is the maximum distance from which a python can detect your...
  25. A

    Python help with sequences and elements?

    Homework Statement My professor wants us to program on Python, where we have a certain sequence, for example: sequence = ("one", "two", "three", "four") I need to replace one of the sequence elements (example: "one") with another element (example: instead of the word "one", I need to put...
  26. P

    Need Help Learning Python Quickly?

    Do anyone know of a good detailed book or website that would help me learn Python quickly? I have assignments that must be done in Python for one of my physics courses. I'm supposed to know how to do it since last semester but had a greater deal of trouble picking up on it and didn't have much...
  27. DrClaude

    Computational physics textbook using python

    I'm looking for a textbook on computational physics based on python. For now I have found Computational Physics with Python by Mark Newman, which I am trying to evaluate. If you have experience with this book or a similar book, I would like to hear from you. (And only if you have knowledge...
  28. G

    CATIA Questions about python script

    Hello,ALL Have somebody used python to Instanciate UDF in CATIA ? I have some question with it As follows: Traceback (most recent call last): File "D:/VSProjects/Python/instantiateTemplate/insTemplateDlg.py", line 80, in on_buttonApply_clicked...
  29. Cake

    Python 2.7.3 or 3.4.1? Which to Learn for Physics/Math

    I have a book for learning python that teaches it with python3 in mind. I also have been using codecademy.com to learn in a more structured way. The thing is that codecademy teaches python from when the most recent form of python was 2.7.3. Their reasoning behind this is that python3 isn't very...
  30. J

    Need help on designing a conceptual HALE UAV

    Hi everyone, I am a High School student (final year) and am doing an extra-curricular project. Having complete autonomy on what we do the project on, I choose to design a High-Altitude Long-Endurance (HALE) UAV, such as the QinetiQ Zephyr [http://www.airforce-technology.com/projects/zephyr/] or...
  31. Kostas Tzim

    Installing Python - Step-by-Step Guide

    Hello, i want to start learning python, but i can't install it after i download python3.4.2 from python's site..then i don't know what to do...it's complicated cause i 've never occupied with programming and it seems hard for me, i'd really appreciate your help
  32. D

    Systems simulated by a simple percolation model using python

    I'm a first year physics student, and one of my assignment for my programming class is about percolation. I need to create some disks randomly distributed in an area (this is a 2-D), and then by varying the density of the disk, I need to figure out the percolation threshold such that the two...
  33. W

    Python - trajectory of a mass in a gravitational frield

    Homework Statement This is just a project for fun, not homework. I'm writing something in python that takes in an apple's initial position vector and initial velocity vector, and for a given gravitational field due to a planet, returns the next position vector after a small time increment...
  34. M

    Interpolation and linear algebra

    Homework Statement As a string in my program. Homework Equations Solving a system with the forward phase of row echelon reduction and a consecutive back substitution. All done by numpy here. (The book suggested MATLAB, etc). The Attempt at a Solution import numpy """ In a wind tunnel...
  35. C

    Exploring Chaotic Billiards: A Simulation and Analysis

    What am I trying to do? I'm trying to implement a simulation of a chaotic billiard system, following the algorithm in this excerpt. How am I trying it? Using numpy and matplotlib, I implemented the following code What is the problem? When calculating phi_new, the equation has two solutions...
  36. L

    How Can I Implement a Three-Variable Advection Equation in Python?

    Homework Statement What I'm trying to achieve is an advection equation that will run using 3 variables. I must confess I don't have a great grasp over this part of my course. Its pretty complicated! Homework Equations The code I have at the moment is: def SolveAdvectionEquation(a, b, t0...
  37. F

    Python code using Process class

    Homework Statement I have the following code (please see below). I want it to return [2,4,6,8,10] which is the function evaluated at the given list [1,2,3,4,5]. I want to do this using the process command. My problem is: print A returns [None, None, None, None, None] But I want it to return...
  38. P

    Is it possible to simulate gravitational waves using python?

    Hello all, Well, I am on my master project named 'General Relativity & Gravitational Waves'. My supervisor asked me if you can simulate gravitational waves by programming it would be a plus. But only programming language I am currently learning is python. Is it possible to simulate some kind of...
  39. E

    How do I run a downloaded python script in github?

    I downloaded a script for python and have no idea how to run it. Do I go into the python GUI or the windows command prompt? Is there any way I can use this in github? Someone told me on another forum said the following. 1. cd /path/to/file 2. python script.py <options here> Which commands do...
  40. J

    Model an FPGA FM Radio Demodulator in Python

    I am trying to model an FPGA FM radio demodulator in Python. I will have a mixer that converts an FM channel to 36MHz IF, and I plan on undersampling this IF signal. If in the digital world (my Python model), I have a high sample rate FM signal at 1.2MHz, should I be able to resample to a...
  41. D

    Solve Python 3 Question Homework: Ear Infection Diagnosis

    Homework Statement You're going to create some medical diagnoses software. You are going to ask the user if they have a fever, a rash, if they have a stuffy nose, and if their ear hurts, and give one of the following responses: Don't have a fever and don't have a stuffy nose: Hypochondriac...
  42. adjacent

    Learning Python & C#: Advice from Real Programmers

    I have am learning python nowadays. I want to learn C# as well. But I fear that I may forget some things of python if I learn C#. I would like to know, from real programmers how you learn all types of programming languages and still remember them. I still haven't learned much python. Just...
  43. adjacent

    Increasing the efficiency of a python code.

    Here is a python function to check whether a given list or string contains duplicate values: def has_duplicates(x): t = [] for i in x: if i not in t: t.append(i) if t != list(x): return True else: return False But I am sure this approach will be slow for...
  44. adjacent

    [Python] Keeping the session alive

    I am experimenting with capatcha images. I have a capatcha.php in my local host which will generate an image and that image will be put into the form Here is my python code to get the image, extract the text in it and send them back to the form. And finally save the resulting form as html...
  45. E

    ND Fourier Transform in Python

    Hi, My aim is to get a series of images in 2D space that run over different timestamps and put them through a 3D Fourier Transform. So my 3D FT has 2 spatial axes and one temporal axis. However I have never done anything like this before, and I have a very basic knowledge of Python. So...
  46. Mogarrr

    Why doesn't the makeSix function change the value of the variable?

    I'm reading the online tutorial "How to Think Like a Computer Scientist", which is a Python tutorial. There is an exercise, which I'm trying to figure out. What happens if you call a function and you don't do anything with the result (i.e., you don't assign it to a variable or use it as part of...
  47. DataGG

    Python 2 vs Python 3 in physics

    Hey, This might sound like something that I should have posted to the "computing & technology" forums, but I disagree. I know that beginners should probably start with Python 3 instead of python 2, as "python 2 is legacy and python 3 is the future". I already bought a book on python 2...
  48. M

    Press-Schechter function in python

    I want to write program in python that gives "redshift", range of "M" and range of "dn/dM" as input and plots "Press-Schechter" function and delivers a graph as output. would you please give some hints? I'm beginner in programming and I don't know how to start.
  49. M

    Plotting Press-Schechter using Python

    How can I plot "Press-Schechter" function using Python for redshift 0, 0.5 and 1?
  50. ignacio_cabero

    How can I add pictures to my python game using JGrasp and PyGame?

    Hello. I am creating a text-based video game using python, and I was wondering how I could put pictures from my Mac into the game. I am using JGrasp if it helps to know.
Back
Top