Python Definition and 655 Threads
-
Python Binned Maximum Likelihood fit in python?
Hi, I have been using Python for a while now, but so far for Least-squares fits using curve_fit from Scipy. I would like to start using Likelihood method to fit binned and unbinned data. I found some documentation in Scipy of how to implement unbinned likelihood fit, but I have not managed to...- ORF
- Thread
- Curve fitting Fit Likelihood Maximum Maximum likelihood Python
- Replies: 9
- Forum: Programming and Computer Science
-
D
Python How does one assess progress when learning a programming language?
I'm a physics major (Junior) who would like to learn a programming language. Many suggest Python as a good starting language, so let's suppose that is the language I want to first learn. This isn't for employability or general usefulness; rather, I'm just curious. How exactly does one go about...- dpatnd
- Thread
- C programming C++ programming Language Programming Python
- Replies: 8
- Forum: Programming and Computer Science
-
F
Python How to correctly use the "global" keyword in Python
Hello, I am learning about functions and namespaces and I have a question about the keyword global. Variables defined inside a function are local variables and cannot be used outside of the function by the rest of the program (by using the return keyword, we can assign the value of a local...- fog37
- Thread
- Global Python
- Replies: 4
- Forum: Programming and Computer Science
-
Python Understanding Object Type in Python
As far as I know, there is no object type in python. How it's determined? For instance, we know that 2 is an object and it belongs to the int class. Similarly, 2.1 is an object, and it belongs to the float class. From my research, I have learned that data type ##\equiv## class. Then what the...- Arman777
- Thread
- Python Type
- Replies: 6
- Forum: Programming and Computer Science
-
Python Changing file icon via cmd or python script
Is it possible to change the icon of a file via python or cmd in windows ? In my previous post I hava manage to change folder icon but I am not sure how to do that for files. Any ideas ?- Arman777
- Thread
- File Python
- Replies: 16
- Forum: Programming and Computer Science
-
Python Changing folder icon in desktop.ini via python
I have created this python program to create a desktop.ini file in a test folder and then change the icon of it. However, the program is something like this import os desktop_ini = ["[.ShellClassInfo]\n", "IconResource=C:\\Users\\Arman\\Desktop\\Coding\\Desktop...- Arman777
- Thread
- Python
- Replies: 4
- Forum: Programming and Computer Science
-
F
Python 'hold off' equivalent in python
In MATLAB one can 'hold off' to remove a previously drawn thing on the same graph. How about in python?- feynman1
- Thread
- Equivalent Python
- Replies: 5
- Forum: Programming and Computer Science
-
M
Python Question about a Python for loop
Hi All I'm learning python and have never seen a for loop positioned like this: integers = [4, 5, 7] strings = [str(integer) for integer in integers] I've only ever seen for loops positioned at the beginning of lines. Is this usual? How can I know when this is okay? I think I would have tried...- member 428835
- Thread
- Loop Python
- Replies: 4
- Forum: Programming and Computer Science
-
Python How does Python tell that an integer is actually an integer?
Look at this example, >>> a = 97 >>> type(a) <class 'int'> >>> bin(a) '0b1100001' >>> b = ord('a') >>> b 97 >>> type(b) <class 'int'> >>> bin(b) '0b1100001' Is this means that the string 'a' and the integer 97 stored as the same binary in the memory ? If so then how can python tell the...- Arman777
- Thread
- Integer Python
- Replies: 47
- Forum: Programming and Computer Science
-
How can I implement a multi-task deep learning neural network?
I have 3 classes (A, B, and C). I have 6 features: train_x = [[ 6.442 6.338 7.027 8.789 10.009 12.566] [ 6.338 7.027 5.338 10.009 8.122 11.217] [ 7.027 5.338 5.335 8.122 5.537 6.408] [ 5.338 5.335 5.659 5.537 5.241 7.043]] These features...- user366312
- Thread
- Network Neural Neural networks Python
- Replies: 3
- Forum: Programming and Computer Science
-
Python Functions, naming conventions in Python
Sometimes, when I code something, I am naming the local variables in the function same as the global variable. Such as, my_var = 13 def iseven(my_var): if my_var % 2 == 0: return True return False print(iseven(my_var)) As you can see my_var is defined globally but also used...- Arman777
- Thread
- Functions Python
- Replies: 33
- Forum: Programming and Computer Science
-
Python Solving the heat equation numerically using Python
I want to solve the heat equation numerically. The equation is: $$k \dfrac{\partial^2 T}{\partial x^2} = \dfrac{\partial T}{\partial t}.$$ This is a parabolic PDE. Following this pdf (specifically, equation 7 given on page 3), I wrote the following Python function to implement the explicit...- Wrichik Basu
- Thread
- Heat Heat equation Python
- Replies: 4
- Forum: Programming and Computer Science
-
C
Python Solving 1-D Schrodinger Equation in Python (Scipy) Numerically
I've tried to make an animation using python to demonstrate the 1-D simple harmonic oscillator and step potential examples. Hope that it can be useful for some of you. Have fun~ :) https://blog.gwlab.page/solving-1-d-schrodinger-equation-in-python-dcb3518ce454 By the way, If you are...- corychu
- Thread
- Animation Python Schrödinger Schrodinger equation
- Replies: 2
- Forum: Programming and Computer Science
-
Python Help with the Python package Scipy and the Z-transform please
Hello everyone ! I am working on ultrasound scan and the processing of the signal received by the probe. I made the model I wanted and as I do not have an ultrasound scan machine I want to simulate the signal processing. I will do that with the Python package Scipy and the function...- hugo_faurand
- Thread
- Complex analysis Python Z-transform
- Replies: 1
- Forum: Programming and Computer Science
-
V
Python Adding noise and solving stochastic ODEs in Python
The Coupled ODE Model Below are my coupled differential equations, where the only variable I try to meddle with is the ITMblood. The motivation here is if I try to increase ITMblood (in the next section I will show how I do it), at some concentration of ITMblood (most likely a very huge one) ...- vabsie
- Thread
- Noise Ode system Odes Python Stochastic
- Replies: 11
- Forum: Programming and Computer Science
-
Python Python Packages to Calculate orbits in Schwarzschild Metric
I am looking for a Python Code/Package to calculate the orbits of the time-like and null-like particles in Schwarzschild metric (in spherical coordinates) Does anyone know such package ? Note: I am mostly looking for packages to calculate the RIGHT side of the given images (i.e the orbits...- Arman777
- Thread
- Metric Orbits Python Schwarzschild Schwarzschild metric
- Replies: 6
- Forum: Programming and Computer Science
-
W
Python Python: Are Terms in this List Monotonic?
Given a list [ a,b,c,..., z] in Python, write a program to determine if the terms are monotonic or not. I can do either , and combine theminto a long, clunky program, but trying to see if I can find a succint way of doing both. I have heard that using ' Nums' may do it,but it seems too...- WWGD
- Thread
- List Python Terms
- Replies: 43
- Forum: Programming and Computer Science
-
B
I Why is (N dot N) different for magnitude than for X, Y, Z components?
I have to perform a calculation on my data. Here is an example of data from just one time step (data from other time steps would appear as additional rows). X Y Z Total 2 2 1 3 Total = SQRT(X2 + Y2 + Z2). The calculation I have to do is: (N • N), where "N" is an average. I tried...- bumblebee77
- Thread
- Components Dot Dot product Magnitude Norm Python Vector
- Replies: 22
- Forum: Calculus
-
W
Python Letter-based Strings not Recognized as Strings in Python Reversing
Hi, I have a simple Python algorithm in my Jupyter notebook , to reverse a string. It works well on numerical strings, but when I try to reverse a letter string, I get an error message, e.g., the string abc, I get the error message: name 'abc' is not defined This is my Python code def...- WWGD
- Thread
- Python Strings
- Replies: 17
- Forum: Programming and Computer Science
-
W
Python Overly large Python Jupyter Notebook (.ipynb) files
Hi all, I was looking up my virtual file manager in Python Jupyter and in the listing of notebooks; all similar to each other in size and scope , some files stand out in terms of size for no apparent reasons. I have some 40 notebooks ; all- but- 2 ranging from 10kb to 284kb at the extremes , and...- WWGD
- Thread
- files Python
- Replies: 12
- Forum: Programming and Computer Science
-
G
Python Does anyone know about python flask and wtf forms?....
from flask import Flask, render_template from forms import RegistrationForm @app.route("/register", methods = ['POST', 'GET']) def register(): forms = RegistrationForm() return render_template('register.html',form=forms) from wtforms import Form, BooleanField, StringField...- gtguhoij
- Thread
- Css flask Forms Html Python
- Replies: 2
- Forum: Programming and Computer Science
-
Python Kindly explain this source code for me
Check this link: How to override the copy/deep-copy operations for a Python object? Can anyone explain, in layman's terms, what is going on in this source code? from copy import copy, deepcopy class MyClass(object): def __init__(self): print('init') self.v = 10...- user366312
- Thread
- Code Explain Python Source
- Replies: 2
- Forum: Programming and Computer Science
-
B
How to write basic syntax for triangle recursion?
Hi, I'm new to programming in python [total beginner in programming] and I would like to ask you for your help. Here is what I got so far: import numpy as np import random from math import sqrt p = np.array([(0, 0), (1, 0), (1, (1/sqrt(2)))], dtype=float) t = np.array((0, 0)...- bolzano95
- Thread
- Programming Python Recursion Triangle
- Replies: 8
- Forum: Programming and Computer Science
-
T
Python Scientific Computing: Method of Undetermined Coefficients in Python
In a self learning project I am fooling around book https://faculty.washington.edu/rjl/fdmbook/ I want to do some of the computation myself to better understand the concepts but the book is Matlab based and Matlab is too expensive. Does anyone by any chance have some of the codes provided by...- the_dane
- Thread
- Coefficients Computing Method Python Scientific Scientific computing Undetermined coefficients
- Replies: 5
- Forum: Programming and Computer Science
-
What happens when large integers are involved?
I've written a program to factorise large numbers (although not that large). The following arithmetic operation goes wrong: x= int(912_321_155_211_368_155/(5)) The result is 182_464_231_042_273_632 Which is clearly not right (should end in 631). The maximum integer on the 64-bit version is...- PeroK
- Thread
- Integers Python
- Replies: 11
- Forum: Programming and Computer Science
-
F
Python Understanding Pickle & JSON Serialization in Python
Hello, I understand that pickle and json are two different modules to serialize Python data. Serialization means to convert an object into a string. When using pickle, we convert the Python data into a binary file. With json, the data is converted into a json file which is essentially a...- fog37
- Thread
- Python
- Replies: 10
- Forum: Programming and Computer Science
-
Python Problem importing matplotlib in Python
I'm running Python 3.8.3 on Windows 10 and was have installed matplotlib, but I can't get it to work. If I try import matplotlib then first it seems to spit out some output (always the same) from a couple of basic test programs I wrote (which is really weird), then just gets a bunch of errors...- PeroK
- Thread
- Matplotlib Python
- Replies: 8
- Forum: Programming and Computer Science
-
F
Python Understanding where pip saves the downloaded Python modules
Hello, I have been trying to figure out where things are stored in Windows. For example, I have two versions of Python, one is stored in the PYthon37 folder and one in the Anaconda3 folder. See below: I have been using pip at the command prompt to install packages/modules and when typing at...- fog37
- Thread
- Modules Python
- Replies: 16
- Forum: Programming and Computer Science
-
Python What's wrong with this Python program on Euler's forward algorithm?
Here is the function that I have written: import numpy as np def ode_euler_forward(odefun, y_initial, x_range, num_steps): """ Solves a system of non-stiff ODEs using Euler's forward algorithm. Parameters ---------- odefun : callable(x, y1, y2, ...) The function...- Wrichik Basu
- Thread
- Algorithm Program Python
- Replies: 2
- Forum: Programming and Computer Science
-
Python Is there a Python function that finds an unknown inside an integral?
I have a integral with unknown h. My integral looks like this where C, a, b are constants F(x) and G(x) are two functions. So the only unknows in the integral is h. How can I solve it ? I guess I need to use scipy but I don't know how to implement or use which functions. Thanks- Arman777
- Thread
- Function Integral Python
- Replies: 3
- Forum: Programming and Computer Science
-
F
Python Python Dot Notation: Access Functions, Classes, Objects & Variables
Hello (again). I have become quite familiar with the dot notation in Python. The dot "operator", assuming operator is the right term, seem to have many uses. For example: 1) After an instance name, it can be used to access instance attributes and apply instance methods to the object/instance...- fog37
- Thread
- Dot Notation Python
- Replies: 25
- Forum: Programming and Computer Science
-
F
Python What Are Python Special Methods and Their Purpose?
Hello Forum, In Python, methods are functions which are defined inside a class. Python has many reserved keywords and built-in functions like print(), add(), type(), etc that we commonly use even when we don't create classes, instances, etc. Whenever we use an operator (like + or - ) or a...- fog37
- Thread
- Classes Python
- Replies: 4
- Forum: Programming and Computer Science
-
Python Finding the stability of a system using Python code
I'm given this code to plot the system for task 1 where my teacher have used some random numbers just to show us how the code can be used: The code makes a plot that is given below: So my professor just gave us this code and plot without saying anything more. All the students in the class...- appletree23
- Thread
- Code Python Stability System
- Replies: 4
- Forum: Programming and Computer Science
-
B
Python Minimization likelihood function with parameters
Hallo at all! I'm learning statistic in python and I have a problem to show you. I have this parametric function: $$P(S|t, \gamma, \beta)=\langle s(t) \rangle \left( \frac{\gamma-\beta}{\gamma\langle s(t) \rangle -\beta}\right)^2\left( 1- \frac{\gamma-\beta}{\gamma\langle s(t) \rangle...- BRN
- Thread
- Function Likelihood Maximum likelihood Minimization Parameters Python
- Replies: 6
- Forum: Programming and Computer Science
-
F
Python Questions about the for loop, iterable, iterator in Python
Hello, I understand that a ##for## loop is intended to repeat the same code a finite and specified number of time. The loop syntax is for i in iterable: statement(s) for = keyword i = counter variable iterable = any iterable (list, tuple, dictionary, range()) statements = body of the...- fog37
- Thread
- Loop Python
- Replies: 16
- Forum: Programming and Computer Science
-
Z
Python Tackling Boundary Conditions in Python (Griffins Example)
How to run a numerical simulation of Laplace equation if one of the boundary condition is like this: $$V(x,y) = 0 \text{ when } x \to \infty$$ I am trying to use Python to plot the solution of this Example 3.5. in Griffins EM- zhuang382
- Thread
- Boundary Boundary conditions Conditions Example Finite difference method Laplace equation Python
- Replies: 1
- Forum: Programming and Computer Science
-
Python A useful software: schematics drawing package for Jupyter (python)
Just wanted to give a shoutout to SchemDraw, a FOSS circuit schematic drawing package for Jupyter(Python), made by a PhD at Sandia Labs. It's purely drawing, not simulation of any kind, but given Python's numeric and symbolic superpowers it's easy enough to bolt-on that functionality. If...- theycallmevirgo
- Thread
- Drawing Python Schematics Software
- Replies: 2
- Forum: Programming and Computer Science
-
Python How to Continuously Iterate Through a Linked List in Python Using urllib
import urllib.request import urllib.request request_url = urllib.request.urlopen( 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345') print(request_url.read()) I have a code somthing like this which prints "and the next nothing is 44827" Now is there a way to get...- Arman777
- Thread
- Python
- Replies: 3
- Forum: Programming and Computer Science
-
Python Running Electrum in Python from the CLI on Ubuntu 20
I'm trying to run electrum (written in python) from the command line on Ubuntu 20. I have 2 similar computers. The first one has version 4.0.4 and once in the electrum folder, I type electrum (the name of the executable file) and it executes whatever command I ask for. My problem is with my...- jack action
- Thread
- Python Running Ubuntu
- Replies: 2
- Forum: Programming and Computer Science
-
Python Python code to calculate the age of the Universe using the Hubble constant
honestly just need some help here i understand the physics just not how to code it or the syntax of python- k1120
- Thread
- Age Code Constant Hubble Hubble constant Python Universe
- Replies: 1
- Forum: Programming and Computer Science
-
Python Looking for online/book Problems about the Python Classes
I started to learn classes in python and I am looking for problems about them. Are there any good online sites that I can find problems about them. If they also contain solutions, that would be great, but if not that is also okay. Problems can have the form like An administrator is a special...- Arman777
- Thread
- Classes Python
- Replies: 5
- Forum: Programming and Computer Science
-
Python İmport a python function inside a subfolder
I have a project folder called Projects and inside that folder I have a file called my_functions.py. Now I have a folder named Project 1 and inside there is another python file called test.pySo it is something like -Projects- my_functions.py -Project 1- test.py Now I...- Arman777
- Thread
- Function Python
- Replies: 17
- Forum: Programming and Computer Science
-
T
Java First, second, third and fourth generation + Python and Javascript
Good Morning I have understood, as a general rule and category (and I realize all such attempts to categorize are fraught with danger), the four generations of languages, from as machine (first generation), to assembly (second generation), to compilable (third generation; e.g., C, FORTRAN) and...- Trying2Learn
- Thread
- Generation Javascript Python
- Replies: 6
- Forum: Programming and Computer Science
-
E
Python Online course for probability and statistics with emphasis on python
I have been looking for a way to learn probability and statistics online and have searched but found nothing yet. I am looking for a course on probability and statistics that will not only teach me the basics but all there is to know about the subject. I would love it if the visualizations are...- Emekadavid
- Thread
- Course Online course Probability Python Statistics
- Replies: 1
- Forum: Programming and Computer Science
-
I How Does Finite Size Scaling Reveal Cluster Behavior in 1D Percolation?
Hello I am struggeling with a problem, or perhaps more with understanding the problem. I have to simulate a one dimensional percolation in Python and that part I can do. The issue is understanding the next line of the problem, which I will post here: "For the largest cluster size S, use finite...- Mikkel
- Thread
- One dimensional Percolation Python
- Replies: 5
- Forum: Atomic and Condensed Matter
-
Z
Cprev and Self.C are referring to the same NumPy
I've encountered this really weird bug in Python. Below is a snippet from a class method. The error occurs where I've placed the two print statements. The update method has absolutely nothing to do with Cprev. The update function changes the value of the attribute self.C. However, the two print...- Zap
- Thread
- Bug Python
- Replies: 11
- Forum: Programming and Computer Science
-
I
Python Redundancy in __init__ in python?
Here is an example code in python, describing a class of fruits: class Fruits(object): def __init__(self, color, taste): self.color = color self.taste = taste If, in general, we ALWAYS do this: class ExampleClass(object): def __init__(self, property1, property2)...- Isaac0427
- Thread
- Python
- Replies: 7
- Forum: Programming and Computer Science
-
F
Python Understanding Python Module Installation with Pip
Hello, I understand that modules are essentially Python file save as .py. These files contain both functions and/or classes. To use them in our programs, we must use the keyword import. However, this works only if the module is available, i.e. already installed in the standard Python library...- fog37
- Thread
- Modules Python
- Replies: 8
- Forum: Programming and Computer Science
-
O
Problem in solving differential equation
Hello everyone! I was studying chaotic systems and therefore made some computer simulations in python. I simulated the driven damped anhatmonic oscillator. The problem I am facing is with solving the differential equation for t=0s-200s. I used numpy.linspace(0,200,timesteps) for generate a time...- Oliver321
- Thread
- Chaos Computation Differential Differential equation Python
- Replies: 3
- Forum: Programming and Computer Science
-
I
Python Trying to understand Why () in Python
I am still on the basics of python, so the odds are if you use a lot of fancy terms I will not understand the answer yet. It is just really confusing me. Thank you!- Isaac0427
- Thread
- Python
- Replies: 13
- Forum: Programming and Computer Science