Python Definition and 655 Threads
-
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...- fog37
- Thread
- Python
- Replies: 23
- Forum: Programming and Computer Science
-
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...- fog37
- Thread
- Python Structures
- Replies: 15
- Forum: Programming and Computer Science
-
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...- fog37
- Thread
- Function Python
- Replies: 9
- Forum: Programming and Computer Science
-
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- Amathproblem22
- Thread
- Ir Line Project Python Robot Sensor
- Replies: 1
- Forum: Programming and Computer Science
-
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...- WWGD
- Thread
- Data Python Structures
- Replies: 8
- Forum: Programming and Computer Science
-
B
Simulate the temperature inside an aquarium tank
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...- bartlino
- Thread
- Aquarium Heat and mass transfer Hvac Python Tank Temperature Thermodaynamics
- Replies: 4
- Forum: Mechanical Engineering
-
Python Starting to Learn Python: Development Tools and Environments
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...- PeroK
- Thread
- Python Tools
- Replies: 56
- Forum: Programming and Computer Science
-
W
Python Elementary Python Questions: Data Frames, k-nary functions
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...- WWGD
- Thread
- Data Elementary Frames Functions Python
- Replies: 8
- Forum: Programming and Computer Science
-
Python How to plot a function with multiple parameters on the same set of axes
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...- Daniel Lima
- Thread
- Axes Function Multiple Parameters Physcis Plot Programming Python Set
- Replies: 6
- Forum: Programming and Computer Science
-
Python Finding a local max/min of a function in Python
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 ...- Eclair_de_XII
- Thread
- Function Local Python
- Replies: 7
- Forum: Programming and Computer Science
-
T
Java Should I enroll in a python course or java? (I’m studying physics)
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...- Theonefrom1994
- Thread
- Course Java Physics Python
- Replies: 9
- Forum: Programming and Computer Science
-
S
Python X error correction code in ProjectQ Python
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...- Spark-X
- Thread
- Code Correction Error Python
- Replies: 1
- Forum: Programming and Computer Science
-
M
Python Running CFD with python and bash: not in agreement
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...- member 428835
- Thread
- Cfd Python Running
- Replies: 21
- Forum: Programming and Computer Science
-
Python Plotting the solution of the central equation using python
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...- patric44
- Thread
- Plotting Python
- Replies: 5
- Forum: Programming and Computer Science
-
V
Python Minimizing a function in python
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...- ver_mathstats
- Thread
- Function Python
- Replies: 2
- Forum: Programming and Computer Science
-
V
Python Graph tan and arctan with python
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...- ver_mathstats
- Thread
- Graph Python Tan
- Replies: 8
- Forum: Programming and Computer Science
-
Computing the wave function of a square potential
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...- CrosisBH
- Thread
- Computational physics Computing Function Potential Python Quantum Square Wave Wave function
- Replies: 4
- Forum: Advanced Physics Homework Help
-
V
Python Calculating Riemann Sums on Python w/ Numpy
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...- ver_mathstats
- Thread
- Python Riemann Riemann sums Sums
- Replies: 4
- Forum: Programming and Computer Science
-
Python Creating noise images with Python and OpenGL
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?- Avatrin
- Thread
- Images Noise Python
- Replies: 5
- Forum: Programming and Computer Science
-
S
Python Python: inverse of a block matrix
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 =...- sifatraquib
- Thread
- Block Inverse Matrix Python
- Replies: 2
- Forum: Programming and Computer Science
-
Python How to Visualize a Matrix with Non-Numeric Values in Python?
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...- Jozefina Gramatikova
- Thread
- Matrix Python
- Replies: 4
- Forum: Programming and Computer Science
-
S
Python How to Catch and Print Assertion Errors in Python
I would like to make output only read: Traceback (most recent call last): AssertionError ... without giving the File "<input>", line 1, in <module>- Sunwoo Bae
- Thread
- Coding Error Python
- Replies: 5
- Forum: Programming and Computer Science
-
T
Python Why Order Matters in an 'and' Statement
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)...- Taylor_1989
- Thread
- Python
- Replies: 5
- Forum: Programming and Computer Science
-
V
Python Is My Python Bisection Method Code Correct?
import math def poly(x): return (x**4 + 2*x**3 - 7*x**2 - 8*x + 12) def bisect(f,a,b,tol=1e-6): while (b-a)>tol: m=(a+b)/2 if (f(a)>=0>=f(m)) or (f(a)<=0<=f(m)): b=m else: a=m return (f(a),a) print(bisect(poly,-4,-2.5)) Here is...- ver_mathstats
- Thread
- Bisection method Method Python
- Replies: 1
- Forum: Programming and Computer Science
-
Python Numerical modeling of a glacier's length -- Coding error(s)
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...- Mikkel
- Thread
- Coding Geophysics Length Modeling Numerical Python
- Replies: 6
- Forum: Programming and Computer Science
-
R
Python Can I ask some basic Python installation questions?
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...- RPinPA
- Thread
- installation Python
- Replies: 8
- Forum: Programming and Computer Science
-
V
Python A derivative/limit calculator using python
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...- ver_mathstats
- Thread
- Calculator Python
- Replies: 14
- Forum: Programming and Computer Science
-
Python RIP Python Terry Jones: Remembering A Legend
https://www.bbc.com/news/entertainment-arts-51209197- gmax137
- Thread
- Python Rip
- Replies: 9
- Forum: Programming and Computer Science
-
W
Python Python 3 Anaconda:Syntax Error on inexistent line#
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...- WWGD
- Thread
- Error Line Python
- Replies: 27
- Forum: Programming and Computer Science
-
B
Python Second programming language to get under the belt: python vs C
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...- Barbradipo
- Thread
- Belt C++ Choice Dft Fortran Language Programming Python
- Replies: 9
- Forum: Programming and Computer Science
-
N
Python Python, scipy.integrate.solve_ive, a problem with plotting a graph
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 = []...- Natchanon
- Thread
- Graph Plotting Python
- Replies: 6
- Forum: Programming and Computer Science
-
W
Python Getting this Array to be in 2D instead of 1D for Python Linear Regression
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 =...- WWGD
- Thread
- 1d 2d Array Linear Linear regression Python Regression
- Replies: 22
- Forum: Programming and Computer Science
-
Python Subscript problem for greek letters in python print function
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 = [...- Arman777
- Thread
- Function Python
- Replies: 6
- Forum: Programming and Computer Science
-
L
Python Intermediary projects in Python (Biophysics)
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...- LionCereals98
- Thread
- Biophysics Projects Python Undergrad
- Replies: 1
- Forum: Programming and Computer Science
-
Python How can I fix a ValueError when trying to terminate a while loop in Python?
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...- antoniacarol
- Thread
- Coding Computer programming Loops Python
- Replies: 11
- Forum: Programming and Computer Science
-
C
Python How can I evaluate a Chebishev polynomial in python?
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...- confused_engineer
- Thread
- Chebyshev polynomials Polynomial Python
- Replies: 3
- Forum: Programming and Computer Science
-
W
Python Same file name, Different Files (Different Content) Python 2.7 Jupyt
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...- WWGD
- Thread
- File files Python
- Replies: 7
- Forum: Programming and Computer Science
-
Python Easy Guide for Installing Pillow and Pygame on Windows XP with Python 3.4.3
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...- cobalt124
- Thread
- Python
- Replies: 6
- Forum: Programming and Computer Science
-
W
Python Python 2.7 Pandas BSoup4 Scrape: Outputs Column Names but not the Data
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 =...- WWGD
- Thread
- Column Data Python
- Replies: 7
- Forum: Programming and Computer Science
-
W
Python Figuring out "Definition" in Python 2.7 Anaconda Birthday Dictionary
--- 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...- WWGD
- Thread
- Definition Python
- Replies: 10
- Forum: Programming and Computer Science
-
K
Python How can I multiply elements in nested lists in Python and print the new list?
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?- Kolika28
- Thread
- List Python
- Replies: 15
- Forum: Programming and Computer Science
-
S
Python Python: printing every other input using a for loop
I want my output to read only the integers. Here's my attempt: number = int(input()) for i in range(2, number+1, 2): print(input())- Sunwoo Bae
- Thread
- Coding Input Loop Printing Python
- Replies: 2
- Forum: Programming and Computer Science
-
F
Python Is Turtle a Module or Library in Python?
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...- fog37
- Thread
- module Python
- Replies: 2
- Forum: Programming and Computer Science
-
F
What Does the -c Flag Do in conda install?
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...- fog37
- Thread
- Python
- Replies: 1
- Forum: Programming and Computer Science
-
T
Python Converting List and tuples using str() function
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...- Taylor_1989
- Thread
- Function List Python
- Replies: 3
- Forum: Programming and Computer Science
-
Python Python 3.7.4 lacks a proper linspace function?
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...- Wrichik Basu
- Thread
- Function Python
- Replies: 2
- Forum: Programming and Computer Science
-
W
Python Any Experience with SQL Server Dev + Python& ML Server?
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.- WWGD
- Thread
- Experience Python Server Sql
- Replies: 1
- Forum: Programming and Computer Science
-
M
Python Coding Riemann (0,4) Equation in Python - Help Needed!
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- member 657093
- Thread
- Coding Einstein field equation Python Riemann
- Replies: 11
- Forum: Programming and Computer Science
-
B
Python Problem in a simulation with Python
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 = []...- Berti
- Thread
- Python Simulation
- Replies: 3
- Forum: Programming and Computer Science
-
D
How can you visualize ALMA image data using the Viridis colormap?
image_data = fits.getdata(alma_image, ext=0) plt.figure() plt.imshow(image_data, cmap='viridis', vmin=-4, vmax=4) plt.xlim(540,640) plt.ylim(540,640) plt.colorbar(extend='both') plt.clim(0, 1) plt.show()- dcc
- Thread
- Astronomy Data Image Python
- Replies: 1
- Forum: Advanced Physics Homework Help