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
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...
there's a website to size an aquarium heater or chiller.
This is just for learning purposes (not for fish) but I have modified these parameters from default to perform a load calculation on a 100 gallon glass tank... For the tank temperature range I set to be between 150-160 degree F. and a...
I finally decided to learn how to program in Python. The basic syntax seems easy enough, but I have a few questions:
There is a dizzying array of editors and IDE's out there. What is a good option to get started?
I've never programmed (or done anything technical) on Windows. Is there any...
Hi All,
A couple of questions, please:
1) Say df is a dataframe in Python Pandas, and I select a specific column from df:
Y=df[column].values.
What kind of data structure is Y?
2)
I want to find the sum of two numbers:
Def Sum(a=0,b=0):
return a+b
If I want to find a sum over sum data...
I attached a file with some explanations of the variables in the code and the plot that I should get. I don't know what is wrong. Any help will appreciated.
from scipy.integrate import quad
import numpy as np
from scipy.special import gamma as gamma_function
from scipy.constants import e...
Okay, so my algorithm looks something like this:
====
1. Locate mid-point of the interval . This is our estimate of the local max.
2. Evaluate .
3. Divide the main interval into two subintervals: a left and right of equal length.
4. Check to see if there is a point in the interval such that ...
Python based course or java course ?. I will be taking an introductory computer programming course . One is python based and the other is java based. The java based course has 2 semesters and goes more in depth with programming . Would it be useful to just take the java courses and get the...
I have been trying write a code in for error correction. I am new to programming and am unable to understand what is not alright. Can anyone please suggest some explanation?
from projectq.ops import All, CNOT, H, Measure, Rz, X, Z
from projectq import MainEngine
from projectq.meta import...
Hi PF!
I'm running a CFD (computational fluid dynamics) program OpenFOAM. Liquid is sucked from a tank, where the velocity at the tank outlet (suction point) is controlled by a python script. The boundary condition for velocity at the outlet is below, line 4 being the velocity prescribed at...
hi guys
i was trying to came up with a basic code that could show me the band gaps in a solid after adding the periodic potential term to my solution :
$$ E = \frac{ħ^2q^2}{2m} \pm Vg $$
where Vg is my periodic potential , q is the k values in the first billion zone
from my understanding if i...
The function is f(x)=x5-12x3+7x2+2x+7.
I found the minimum of the function and compared the value to a calculator and it seemed okay. But I am confused as to how to incorporate the interval into my code. Has my code already sufficiently answered the question?
from scipy import optimize...
import numpy as np
import matplotlib.pyplot as plt
x=np.arange(-5*np.pi, 5*np.pi, step = 0.02)
plt.ylim(-1, 1)
tan=np.tan(x)
arctan=np.arctan(x)
plt.plot(x,tan)
plt.plot(x,arctan)
Here is the code I came up with using the guide my teacher gave me, is this correct the way I have done it? Thank...
The book's procedure for the "shooting method"
The point of this program is to compute a wave function and to try and home in on the ground eigenvalue energy, which i should expect pi^2 / 8 = 1.2337...
This is my program (written in python)
import matplotlib.pyplot as plt
import numpy as...
import numpy as np
def num_int(f,a,b,n):
dx=(b-a)/n
x=np.arange(a,b,step=dx)
y=f(x)
return y.sum()*dx
def rational_func(x):
return 1/(1+x**2)
print(num_int(rational_func,2,5,10))
Here is my code for the left endpoint, I know this code works because I compared it to an...
Hi
I am learning how to do a line integral convolution with OpenGL given a vector field. So, as a first step, I need to learn how to create an nxn noise image. Are there any good tutorials/books I can use to learn how to do this?
I am using the following code. It's returning the block matrix (Z) raised to negative one (think about inputting 22/7 in a Casio fx-991ES PLUS).
import sympy as sp
from IPython.display import display
X = sp.Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
i = sp.Matrix([[1], [1], [1]])
Z =...
As part of a group project, we have been asked to create a code which produces the following matrix:
I want to create the graphics of this in a way that looks similar to this:
But of course with different number of cells, different colours, etc. The problem is that from what I have found...
I am currently doing a leet code problem and came across something, I have not noticed before.
Here is a sample of the code I am working on.
s = "10#11#12"
A=[]
B=[]
i=0
count=0
while i < len(s):
if i+2<len(s) and s[i+2]=='#':
A+=[(s[i]+s[i+1]+s[i+2])]
i+=3
print(i)...
Hey Physics Forum
I am currently doing my bachelor project in geophysics, with focus on the evolution of glaciers in Greenland. My project consists partly of programming, because I want to get better at it. I have, however, hit a wall. I can't seem to figure out what is wrong with my code and I...
I finally decided to do something I've been meaning to do for a couple years, namely learn Python. I opted for a Coursera course sponsored by IBM. They provide a "lab" that has everything you need to write and test code fragments in Python 3.
But now I'm at the point of wanting my own...
import math
def derivative_quotient(f, a, h):
return float((f(a + h) - f(a)) / h)
if h==0:
return "Division by zero is not allowed."
Here is my code so far, I am unsure of where to go from here or if I am even on the right track. I am a little confused what it means by "where...
Ok, I wrote a small program P, initially of 16 lines in Jupyter Anaconda in Python 3.7
I deleted the last 4 lines, ending up with 12 lines in P2.
Now, I run P2 and I'm told there is a syntax error in (the inexistent) line 14.
I restarted the kernel, nothing. I opened another notebook, pasted...
Hello everybody,
I am a master student in Theoretical Chemistry and I am working in the DFT realm. Both TDDFT and DFT applied to extended systems (eg. using QUANTUM ESPRESSO). Of course I work with these softwares from a end-user point of view, not as a developer.
But anyway, even if some of...
Hi, I have this code that solve the equation of motion of a relativistic electron.
from math import sqrt
from scipy.integrate import odeint, solve_ivp
import numpy as np
import matplotlib.pyplot as plt
e = 1.602 * 10 ** (-19)
E = 10 ** 6
m = 9.106 * 10 ** (-31)
def d2vdt2(t,r):
t_arr = []...
import matplotlibimport matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model
import pandas as pd
# Load CSV and columns
df = pd.read_csv("C:\Housing.csv")
Y = df['price']
X = df['lotsize']
# Split the data into training/testing sets
X_train = X[:-250]
X_test =...
I am trying to create a GUI for a phyiscs project and I need subscripts of these things.
`H_0`,
`Omega_b`,
`Omega_dm`,
`Omega_\Lambda`
`Omega_r`
in the form of latex
My code is something like this
import PySimpleGUI as sg
sg.change_look_and_feel('Topanga')
layout = [...
Hello,
I am an Undergraduate student looking for ideas for a project in Python. The project should contain a library filled with modules, classes (and preferably something with inheritance), and the unittest module.
I would like to do something as follows: First, some kind ob WebScraping to...
Please help!
I am trying to create a Python program for an assignment that will convert Celsius to Fahrenheit and vice versa depending on the input from the user. The numeric conversion portion of the code is working, however, if the user inputs "exit" the while loop is supposed to terminate...
Hello everyone. I need to construct in python a function which returns the evaluation of a Chebishev polynomial of order k evaluated in x. I have tested the function chebval form these documents, but it doesn't provide what I look for, since I have tested the third one, 4t^3-3t and
import numpy...
So I have Python 2.7 ( Don't ask) installed in my VM.
Now I have two files named " Untitled 10" in my Jupyter notebook therein ( Notice the bottom cell in both files , named "Untitled 10" -- please see top of attachments -- which have different content in the "bottom-most" cell ); please...
I'm using Windows XP without Internet access with Python 3.4.3 installed. I wish to install Pillow and Pygame, but can't get them to install correctly. I'm going round in circles on the Internet, StackExchange and other sites. I've tried using:
Pillow-5.4.1.win32-py3.4.exe...
Hi, trying to scrape a page :
https://www.hofstede-insights.com/wp-json/v1/country
I get the list of columns I want, but not the data assigned to the columns in the page that is being scraped.
from bs4 import BeautifulSoup
import pandas as pd
import requests
url =...
--- Say we have the dictionary in Anaconda 2.7 Jupyter :---
B={'A1':'Jan1' , 'A2':'Feb2',...} of Birthdates.
---I can call a name , e.g., 'A1' , using Birth[name]. As in :---
print('What is your name '\? ')
name=input()
print('Yes, Birth[name] is in our list')
---How do I call a Date? I want...
I have a list containing several lists with two elements each. I want to multiply the last element in the inner lists with a number x, and then print the new list. How do I do this?
Hello,
I am trying to fully understand the difference between module, library, and package in Python.
I think a module is a single file with a specific functionality.
A library is like a directory: it contains multiple files, i.e. multiple modules.
A package contains multiple libraries and...
Hello Everyone,
I am trying to install OpenCV, which is a library for image processing. I am downloading the Python Anaconda distribution where to use OpenCV. I read that the following commands are needed at the prompt:
conda install -c conda-forge opencv
install means install the library...
I am currently working my way through some w3schools python exercise on tuples and lists etc and one question was to write a program to converted a tuple to a string.
Now originally I used the str() function on the tuple and printed the result. I then used the string in a for loop for a...
Basically, I wanted to create a Numpy array with linearly spaced integers between 0 and 3, the increment being 0.01.
Yes, I know Numpy offers a linspace function. I used it like this: x = np.linspace(0, 3, num=300) (where np is numpy), and got this:
I know that the numbers cannot be exact...
Hi all,
Curious if anyone has worked with SQL Server Dev 2017 with ML and Python Server, i.e., with the full data analysis platform and what your experiences are.
Hi,
I've coded Riemann tensor in python successfully. However, I recently stumbled onto another Riemann equation for the valence (0,4) as shown in the following link: Riemann (0,4)
I'm having troubled coding the last part after the partial derivatives and the plus sign. Can anyone help me? Thanks
I wanted to simulate the Ising model and it was okay until I wanted to get the fluctuations <M^2>.
In fact, first, I wanted to obtain the magnetization M :
$$ M = \sum_i \sigma ^ z_i $$
and it worked, I got indeed the magnetization M by writing these lines :
sigmaxop = []
sites = []...
I’ve been looking for a certain type of software that can host programming (preferably C or Python) and other process that I’m going to need such as DSP, DSP filters, diagrams (3D graphs, charts,…), and text editing within the same file. It’s mainly so that I can incorporate and use each one...
I am trying to solve the equation like this,
from sympy.solvers import solve
from sympy import Symbol
import math
x = Symbol('x')
A, B, C, D = 0.59912051, 0.64030348, 263.33721367, 387.92069617
print(solve((A * x) + (B * math.sqrt(x**3)) - (C * math.exp(-x / 50)) - D, x , numerical = True))...
I am currently learning python and to understand the my code fully and to make notes I am trying to draw flow charts to compliment my code. My issue is I am not sure what to put in the flow charts or really how to represent them as clearly as possible. I have done a google search but I am bit...