Python Definition and 655 Threads
-
S
Python Noob question re Python on Windows PC
Hi I want to start learning Python and am a little nervous about installing it (from www.python.org) and running it on my main Windows Vista PC. I have scary memories from previous programming experience over 20 years ago of it being possible to corrupt important files or bits of memory by...- sdo62
- Thread
- Noob pc Python Windows
- Replies: 3
- Forum: Programming and Computer Science
-
E
Python Ideas for simple programs to write in Python please
I currently have little experience in programming and would like to improve my skills. The most complex program I've made so far has been a definite integral calculator that uses either right handed or left handed riemann sums to approximate the definite integral (although it fails to be...- ecneicS
- Thread
- Ideas Programs Python
- Replies: 6
- Forum: Programming and Computer Science
-
D
Python Quick Python color coding in editing question
When I've been programming in Python for a while I noticed that the color coding in IDLE goes away. If I restart IDLE, the colors come back. Why is it doing this? How can I maintain the color in there without having to restart a bunch of times? Thanks- DrummingAtom
- Thread
- Coding Color Python
- Replies: 2
- Forum: Programming and Computer Science
-
S
Python How Can I Correct My Python Regular Expressions Code for Analyzing Swallow Data?
Homework Statement This isn't really a homewrok/coursework question, but I didn't know where to put it. I'm trying to teach myself python over the summer and I seem to have got stuck on regular expressions. I want to read a .txt file with data for various kinds of swallows, laden/unlden...- Schr0d1ng3r
- Thread
- Expressions Python Regular
- Replies: 1
- Forum: Programming and Computer Science
-
B
Python Python code for mapping numbers n text file
Dear Programmers I am having text file having huge data. From the text file i would like to map the two numbers that are present in the same brackets and the values should not considered if they are present in different numbers. say for example I want to map number "4758 & 3895" that are in...- Bala06
- Thread
- Code File Mapping Numbers Python Text
- Replies: 2
- Forum: Programming and Computer Science
-
H
Python Learn Python for Physics: Introduction vs Scientific Programming
Is it better to start learning Python using a introduction to python book (Think Python) or a scientific programming book (e.g. A Primer on Scientific Programming with Python, 2009)? I have little to no programming experience. I'd use python solely for physics computation/simulations. I was...- Headacheguy
- Thread
- Introduction Physics Programming Python Scientific
- Replies: 6
- Forum: Programming and Computer Science
-
Z
Python Opening Files in Python - Newbie Question
Homework Statement Hi, this might be silly but I'm not sure what the syntax is for the read function... I'm trying to open a file on my desktop, it is a text file called testfile.txt, how do I make python know where to find it? I go: f = open('C:\Users\Truman\Desktop\testfile.txt'...- zeion
- Thread
- Python
- Replies: 4
- Forum: Programming and Computer Science
-
Z
Python Don't understand this python function
Homework Statement Hi, I'm not sure what this does: s = 'hello' I understand s[::-1] would reverse the order of the letters and s[1::] slices the first letter but how come s[1::-1] returns 'eh' ? Homework Equations The Attempt at a Solution- zeion
- Thread
- Function Python
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python Beginner Python - simple function
Homework Statement Write the definition of a function typing_speed , that receives two parameters. The first is the number of words that a person has typed (an int greater than or equal to zero) in a particular time interval. The second is the length of the time interval in seconds (an...- zeion
- Thread
- Beginner Function Python
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python Beginner Python - better way to write this?
Hi, This compiles, I just wanted suggestions for fewer lines. Thanks. Homework Statement Need to write a function for this: Given an int variable, return a factor of that int. If the input is not between 0 and 100 return -1. If there are more than one distinct factors, return...- zeion
- Thread
- Beginner Python
- Replies: 26
- Forum: Programming and Computer Science
-
N
C/C++ Python or C++ for ChemE Major: Which is Most Useful?
I'm a chemE major, entering my sophomore year. I have used python in physics classes, but that was minimal experience. I want to begin learning a language this summer; I have no other prior experience. My main interest is cryptography, but I don't think this will amount to anything other...- Null_
- Thread
- C++ Python
- Replies: 20
- Forum: Programming and Computer Science
-
J
Why Doesn't My Blasius Equation Script Match Fluid Mechanics Data?
Hi everybody I'm writing a script in Python to solve the Blasius equation but it does not work (well, script works and it generates the plot), numerical results does not match with data I've seen in fluid mechanics books. Please anyone could help me? Thank you very much Script is...- javiergra24
- Thread
- Python
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python Storing Functions in a List - Python Q&A
Homework Statement Hello, I just have a small question with Python. Is it possible to store multiple functions in a list? So I can call them from the list? Like if I had : def func1(): ... def func2(): ... def func3(): ... Can I put them in a list and call them from...- zeion
- Thread
- Functions List Python
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python Python: Retrieve Function Name Without Execution
Homework Statement Hi there, I just have a quick one here.. Is there a way to bring the NAME of a function? Not execute it? Like if I had def apple(): return Can I get it to print "apple" somehow? Thanks Homework Equations The Attempt at a Solution- zeion
- Thread
- Minor Python
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python How to Replace Digits in a String with Characters from Another String in Python?
Homework Statement Write the follow function: def substitute_digits (s, subst): s is a string and subst is a string of length 10. Return a copy of s, where each digit in s is replaced by the second character of subst, '1' is replaced by the second character of subst, ... , and '9' is...- zeion
- Thread
- Beginner Python
- Replies: 7
- Forum: Programming and Computer Science
-
Z
How can I efficiently capitalize items in a list without modifying the original?
Homework Statement I'm supposed to write a function that does this: def capitalize_items_2(lst): Return a new list with the same items as lst, only in upper case. lst is a list of strings. This function does not change lst Homework Equations The Attempt at a Solution def...- zeion
- Thread
- Beginner Python
- Replies: 10
- Forum: Programming and Computer Science
-
T
Python How can I fix the error in my custom Python exception class?
Homework Statement For an introductory Python course, one of the problems I am required to do involves creating a MyError class that inherits from Exception. Its purpose is to handle possible wrong inputs to the int() function and to return an error statement that includes what was input. I...- tigger88
- Thread
- Python
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python Quick Python question - how to change input to *
Homework Statement Hello, Just a quick question here for Python. I'm using raw_input to get the user to type in a string, but I want the letters to display as * (like when you enter a password) as they type it. (But not actually register as *). Is this doable in Python? Thanks...- zeion
- Thread
- Change Input Python
- Replies: 9
- Forum: Programming and Computer Science
-
K
Python Why is Python Telling Me My Variable is Not Defined?
Homework Statement Hi. So I'm stuck on a few things right now, but the main one is that Python is telling me that one of my variables is not defined. I have stressed over this for about an hour now trying everything to change it, and I cannot seem to find issue. Homework Equations...- katie_3011
- Thread
- Assignment Programming Python
- Replies: 3
- Forum: Programming and Computer Science
-
B
Python Bad form not to use functions in Python?
I have a 100 line code which is liable to increase, so far I have not included any user defined functions, so it is one stream of code. In c I was taught to put everything I could into functions, is this the case in python i.e. would I be frowned upon for not using functions? Many thanks.- bigfoot100
- Thread
- Form Functions Python
- Replies: 2
- Forum: Programming and Computer Science
-
D
Python Loging into a webpage using python.
Hi, I am trying to access some data online, but I am having trouble getting past the actual authentication process. import cookielib import urllib, urllib2 if __name__ == '__main__': urlLogin = 'https://www.hobolink.com' uid = 'userid' password = 'xxxxxxx'...- dacruick
- Thread
- Python
- Replies: 2
- Forum: Programming and Computer Science
-
D
Python How can I log into a webpage using python and access data?
Hello ladies and gentlemen, I have grabbed a code for emailing using python. This isn't my end goal, but I think its a logical place to start and get used to the smtp library. here is the code import smtplib def prompt(prompt): return raw_input(prompt).strip() fromaddr =...- dacruick
- Thread
- Python
- Replies: 8
- Forum: Programming and Computer Science
-
Python Python Else/Elif Syntax Error: Troubleshooting Tips and Common Mistakes
Hello, the title says it all; I am trying to teach myself Python using version 2.7.1 aka matplotlib or PYLAB via the MIT opencourseware as well as the tutorial from the site I downloaded it from; I am having a very frustrating time using it as system continues to return any variant of else...- clope023
- Thread
- Error Python
- Replies: 2
- Forum: Programming and Computer Science
-
Python How can I use Euler's Method in Python to solve a differential equation?
Hi Here's is the differential equation I need to solve using Euler's Method: v' = 5 - 0.5v^2 I need to plot the position x(t), velocity v(t) and acceleration a(t) as a function of time. v(0) is 0 I have the data for time: s = linspace(0, 12, 121) #(delta t is 0.1) But, that's about it...- Avatrin
- Thread
- Euler's method Method Python
- Replies: 13
- Forum: Programming and Computer Science
-
P
Python Learning Python -Beginner Question
Learning Python --Beginner Question Hey All, I am translating a whole lot of code from MATLAB to Python/NumPy/SciPy. However, I am having a lot of trouble creating column vectors. I know that in MATLAB it would go like this: a = [1,2,3,4,5,6,78], colvec = a' if anyone know the...- poobar
- Thread
- Python
- Replies: 4
- Forum: Programming and Computer Science
-
C
Python Dirac Algorithm in Python (or similar)
I was wondering if anybody knows of any code available to perform tensor analysis in Python or in other language; I was wondering if there is any computational method for finding constraints in a lagrangian via the Dirac Algorithm.- CfM
- Thread
- Algorithm Dirac Python
- Replies: 2
- Forum: Programming and Computer Science
-
B
Python Intro to python: using - in / and %
im reading a book intro to python, I am confused by what is ment by the following >>>-17/10 -2 i do not understand this explain pls NOT A HW- Brown Arrow
- Thread
- Intro Python
- Replies: 1
- Forum: Programming and Computer Science
-
C
Python Maintaining Syntax Highlighting in Python IDLE
Homework Statement I am a novice programmer and have just started programming on Python. When one types a command, the commands are highlighted in a certain color. When I open a new window and run the module, the commands lose their color. it is quite annoying. is their trick to keep the...- chillfactor
- Thread
- Python
- Replies: 3
- Forum: Programming and Computer Science
-
W
Python Finding primitive roots using python
Im not sure if this should go in the math/number theory section or here, but here it goes: how do programs calculate the primitive roots mod n of extremely large primes? My program will only go up to 12-14 bits before having memory errors caused by storage of the totient of the prime number...- wrong_class
- Thread
- Primitive Python Roots
- Replies: 9
- Forum: Programming and Computer Science
-
L
Python Fortran Routine calling a Python Function
I have been trying to merge some python with fortran, to build a nice interface but still be fast. I spent the last two days learning how to use f2py, buy everything would be so much easier if I could call a Python function from Fortran instead of doing the other way around. Anyone know how...- LucasCampos
- Thread
- Fortran Function Python
- Replies: 2
- Forum: Programming and Computer Science
-
D
Python Why won't this python code work?
lists = [(2 * i + 1) for i in range(100)] i = 0 while (i < 100): if(lists[i] == 3): lists.remove(lists[i]) i = i + 1 print lists It is giving me an error about the index being out of range. I am new to python and I am not understanding this error. Edit: Fixed it. This is by...- dmatador
- Thread
- Code Python Work
- Replies: 1
- Forum: Programming and Computer Science
-
J
Python How to write a data file in Python
Hi guys I've done a Runge-Kutta script for the Lorenz Equations in python, I need to write data for (t,x,y,z) in a .dat file in order to reprint in a table. How can a do it? Imported routines are: import sys, pylab, numpy from pylab import * from mpl_toolkits.mplot3d import Axes3D...- javiergra24
- Thread
- Data File Python
- Replies: 9
- Forum: Programming and Computer Science
-
D
Python Find Numerical Physics Problems in Python
I'm searching a book, or a place on the net where I'll find tons of examples of numerical problems in physics (mainly quantum mechanics) written in Python. I have tons of books about Python, but none have good examples on problems like tunneling, solving Schrodinger eq for various potentials...- dingo_d
- Thread
- Numerical Physics Physics problems Python
- Replies: 2
- Forum: Programming and Computer Science
-
K
Python Python Beginner Help: Removing Duplicate Words from Lists
Homework Statement I have a simple question with python. I have a text file that's been converted into a bunch of lists like this. [blah, blah] [blah, blah, blah] [a, a, d] [g,x,d,s,a] etc.. now i want to loop over all of these lists and append all the words into a new list...- Kuma
- Thread
- Beginner Python
- Replies: 3
- Forum: Programming and Computer Science
-
T
Python Replacing multiple spaces in Python
Homework Statement Write a function spacereplace(txt) that removes two or more spaces in a row, replacing them with a single space. Any other characters should remain the same. The Attempt at a Solution I tried this: def spacereplace(txt): f=txt.replace(" "," ") return f...- tabc
- Thread
- Multiple Python
- Replies: 1
- Forum: Programming and Computer Science
-
H
Python Python FFT help, non linear scaling
Im writing a program in python to simulate the propagation of a gaussian beam through a thick lens and to the focussing point using Fourier optics. Due to the strength of the focussing I need a lot of data points so that I have a decent resolution at the focus. To speed things up and to...- Hypochondriac
- Thread
- Fft Linear Python Scaling
- Replies: 1
- Forum: Programming and Computer Science
-
D
Python Can Python scipy.optimize.fmin() Optimize More Than One Variable at Once?
Hi All, I am trying to optimize for more than 1 variable at the same time. is that possible?- dacruick
- Thread
- Python
- Replies: 1
- Forum: Programming and Computer Science
-
A
Python How to make scientific notation the default in the Python interpreter?
Hi, I'm tired of reading numbers like 695500000, and using %e all the time is not a practical solution. Thanks.- andresordonez
- Thread
- Notation Python Scientific
- Replies: 2
- Forum: Programming and Computer Science
-
G
Python Stupid Question about Python Learning Curve
Stupid Question about Python Learning Curve :D Sooooo... I have to get some sort of menial minimum wage job in the near future, and I would be okay with this if it gave me the time to study books or think about philosophy (a night clerk/cashier or something, etc.) Regardless of what...- G037H3
- Thread
- Curve Python Stupid
- Replies: 31
- Forum: Programming and Computer Science
-
M
Python What is the Python syntax for checking if a number is a palindrome?
I'm doing the http://projecteuler.net/" problems for garbages and giggles, and was working on problem 4 which requires finding the largest number palindrome (e.g. 10301, 54345) that is the product of two 3-digit numbers. Below is my code, and I'm pretty sure Python will reproduce the error...- mslate
- Thread
- Python Recursion
- Replies: 8
- Forum: Programming and Computer Science
-
D
Python Calculate Area Under Gaussian Curve w/ Python Reimann Sum
Hi I have a program that is to calculate the area under the curve of a Gaussian distribution. The integral from -inf to inf is 1, and my Reimann sum program calculates close to 1.5pi = numpy.arccos(-1) a = 1 / (StandDev * pow(2*pi,0.5)) b = MPCAverage #MPC is the x-axis of my gaussian curve...- dacruick
- Thread
- Python Sum
- Replies: 1
- Forum: Programming and Computer Science
-
Z
Python Python Tutorial for Beginners With Little Programming Knowledge
I've been working with python for about 4 or five months. I understand how to use boolean, a little bit of I/O, making functions, writing my own classes, and importing modules. Pretty much the bare basics. Outside of this python experience, I have little knowledge of programming. So, can...- zakbrown0308
- Thread
- Python Tutorial
- Replies: 3
- Forum: Programming and Computer Science
-
M
Python Learning Python and Sage - Advice Appreciated
I have no backbround in programming or science/mathematics software, but time and desire to learn... is learning Phyton and Sage a good idea? Advice appreciated!- murray92
- Thread
- Python
- Replies: 4
- Forum: Programming and Computer Science
-
V
Python Python: Calculating the average of scores and separatign into letter grades
Homework Statement I'm suppose to write up a program where I need to take a file that contains a list of numbers. Example: 30 40 40 80 and so on, these number represent letter grades. 90~100 = „A‟, 80~89 = „B‟, 70~79 = „C‟, 60~69 = „D‟, all other scores = „F‟. So what I'm suppose to do for...- vipertongn
- Thread
- Average Grades Python
- Replies: 8
- Forum: Programming and Computer Science
-
D
Python Python: Help with bestfit line and outliers
I've been having some trouble with outliers messing up my best fit line on my scatter plot in python. I'm using numpy's polyfit function to calculate the slope and y intercept of the best fit line, however I always seem to get one or two points which throw off the slope enough to make quite a...- DMT
- Thread
- Line Python
- Replies: 1
- Forum: Programming and Computer Science
-
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...- computerex
- Thread
- Circular Circular motion Motion Program Python Uniform Uniform circular motion
- Replies: 1
- Forum: Programming and Computer Science
-
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...- Jonny6001
- Thread
- 1d Convection Linear Python
- Replies: 12
- Forum: Programming and Computer Science
-
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...- brushman
- Thread
- Function Python
- Replies: 1
- Forum: Programming and Computer Science
-
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...- rubrix
- Thread
- Books C++ C++ programming Programming Python
- Replies: 4
- Forum: Programming and Computer Science
-
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 *...- brushman
- Thread
- Python
- Replies: 2
- Forum: Programming and Computer Science