Python Definition and 660 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. Arman777

    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...
  2. 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?
  3. 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...
  4. Arman777

    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...
  5. user366312

    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...
  6. Arman777

    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...
  7. Wrichik Basu

    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...
  8. 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...
  9. hugo_faurand

    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...
  10. 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) ...
  11. Arman777

    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...
  12. 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...
  13. 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...
  14. 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...
  15. 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...
  16. 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...
  17. user366312

    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...
  18. 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)...
  19. 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...
  20. PeroK

    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...
  21. 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...
  22. PeroK

    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...
  23. 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...
  24. Wrichik Basu

    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...
  25. Arman777

    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
  26. 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...
  27. F

    Python Exploring Python Special Methods & Classes

    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...
  28. appletree23

    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...
  29. 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...
  30. 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...
  31. 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
  32. theycallmevirgo

    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...
  33. Arman777

    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...
  34. jack action

    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...
  35. k1120

    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
  36. Arman777

    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...
  37. Arman777

    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...
  38. 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...
  39. 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...
  40. Mikkel

    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...
  41. 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...
  42. 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)...
  43. 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...
  44. 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...
  45. 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!
  46. F

    Python Objects in Python: Integer, Float, List & Classes

    Hello, I get that everything (almost?) in Python is an object. Objects are instances of classes with associated attributes (i.e. characteristics, properties, features) which are essentially variables. Objects also have associated methods (i.e. functions that act on the object or make the object...
  47. F

    Python Nested structures and indentation in Python

    Hello! In the context of Python, indentation is very important and mandatory. The entire code is separated into blocks and each block has its own indentation. Two blocks with the same indentation belong are the same block unless the blocks are separated by a block with less indentation...
  48. F

    Python Python IDLE and print function....

    Hello, While using the IDLE editor, I noticed that it is possible to simply type the variable name, list name, dict name and view its content without using the print() function...For example, if the variable a=5, then I would expect print(a) to output 5. And it does. But I can also simply type...
  49. Amathproblem22

    Python Python & Line Sensor (IR) for Robot Project

    I'm making a robot the will follow a black line and I need some assistance does anyone here have experience with python and line sensors.(IR) If anyone does I can elaborate on my issues more. Thanks
  50. W

    Python Python Data Structures: Guessing a Number

    Hi all, Trying to right a program in Python asking user to guess a number ( integer in finite range) until they make a correct guess, though I want to warn user when guess is too high --asking that they choose a lower number ,and same for when the guess is low, asking them to choose a higher...
Back
Top