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 ?
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...
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...
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...
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...
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...
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...
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...
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) ...
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...
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...
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...
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...
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...
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...
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)...
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...
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...
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...
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...
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...
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...
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
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...
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...
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...
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...
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...
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
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...
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...
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...
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...
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...
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...
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...
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...
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...
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)...
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...
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...
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!
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...
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...
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...
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