Hi,
Question:
Why is the error 'Error parsing inputs' in CVXPy occurring?
Context:
I am trying to solve a semidefinite program in CVXPy (using Google Colab). I went to the documentation (HERE) and I copied the example code into a cell. It doesn't work for some reason and I don't understand...
Hi PF!
I am trying to import k.txt file into Mathematica as a list of numbers. The k.txt looks like this:
[5.315967917338153e-06, -3.204321972222162e-08, 3.6041782425371564e-09, -3.853442465663655e-08, 8.699510604529962e-07, -1.4284341965847237e-08, 2.855341882658808e-09...
I am absolutely new to Polymer simulation. I am trying to understand the simulation by analyzing source code written by others.
Can anyone tell me what are the differences between the following three source code in terms of their objectives?
Monte-Carlo-simulation-of-polymers...
# Test suite for Problem Set 3 (Simulating Robots)
# Fall 2016
import sys
import threading
import traceback
import unittest
import random
import imp
test = imp.load_compiled("test", "test.pyc")
import ps3
def xyrange(x_upper_bound, y_upper_bound):
""" Returns the cartesian product of...
I wanted to declare a local variable inside a static method main().
My code looks like this -
class Operator
{
static int a;
public static void input() {
Scanner in=new Scanner(System.in);
System.out.println("Enter the number:");
a=in.nextInt(); //this is...
https://blog.miguelgrinberg.com/post/how-to-add-flask-migrate-to-an-existing-project
I am using Visual Studio Code and have a database file already created called test.db. My environment variables for test.db name is SQLALCHEMY_DATABASE_URI and the value is sqlite:///test.db In the actual code...
Hi PF!
I followed someone's help on here and have the following code in python that performs monte carlo integration
from math import *
from random import *
def integrate(alpha):
# MONTE CARLO INTEGRATION OVER NON-RECTANGULAR DOMAINS
def f(pt):
# RETURN INTEGRAND AS FUNCTION...
This is in python flask. I am getting an error
line 16, in template <h2> <a href="{{ url_for('userinfo.profile', username=current_user.username, 'update_profile') }}"> update_profile_info </a> </h2>
jinja2.exceptions.TemplateSyntaxError: invalid syntax for function call expression The...
Images comparison
What are the best softwares available for comparing two images having similarity and differences?
Two photos each of Margaret and Enid.
1 Margaret's first photo with her second photo comparison.
2 Enid's first photo with her second photo comparision.
3 Margaret's first...
Hi PF!
I'm trying to write a code that, given a list of integers, will output the next lexicographic permutation. But my output gives me None, and I can't see why. Is it because I am incorrectly calling the reverse function? Any help is greatly appreciated!
class Solution(object):
def...
Hi everyone,
I have to classify a DNA sequence with a LSTM neural network but I have a problem with the inputs shame. Both the sequence and the class are encoded with One Hot Encoding and my code is this:
import pandas as pd
import numpy as np
data = pd.read_csv('splice.data', header = None)...
Hi everyone,
Hopefully I'm writing this in the correct part of PhysicsForum.
Here is my problem:
I'm really struggling with my programming class (basics of python3 - loops, dictionaries, numpy).
What I did this semester:
1. Participated in every class
2. Solved everything our course offered...
Hi PF!
I am looking at the following code
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def removeNthFromEnd(head: ListNode, n: int) -> ListNode:
# Two pointers - fast and slow
slow = head
fast = head
# Move fast...
Hi PF!
I am running VS Code for python on Ubuntu. Is there a way to execute a specific python line? As I currently have it set up, on the terminal input at the bottom of the screen, I can only work through the terminal, so a command like print('hello world') won't do anything.
THanks so mcuh!
Hey! :giggle:
I found online the following code for a christmas tree in Python :
tree_height = input("Enter the tree height : ")
tree_height = int(tree_height)
spaces = tree_height-1
hashes = 1
stump_spaces = tree_height-1
while tree_height != 0 :
for i in range(spaces)...
Hello
I learned object oriented programming in Python from a book. But it does not have any programming exercises. I do not learn very much unless I do some programming exercises. It helps to hone the skills. So, I am looking for some exercises if OOP Python is taught in universities. Usually...
Summary:: I'm not asking for help, but I'm asking for an opinion. Is this a sign that I probably should not be pursuing a career in software development or computer science?
I basically feel like this in general wrt any subject I am studying, really, whenever I feel stumped on a given problem...
Hey! 😊
Construct a class named Vector that expresses the meaning of the vector of numbers. The initialization function, __init__ will take as a argument a tuple corresponding to the vector. This tuple will be stored in the variable named coord. Also, __init__ will calculate the Euclidean...
Hey! :giggle:
Construct a class named Student which when initializing its objects has the following variables :
- first_name (string)
- last_name (string)
- email (string)
The class should also support the following functions implemented as functions (methods):
- set_id_number: set a...
I need to make an application that uses database in python, what should I make?
Firstly I need to tell about me. I know 0 about programming. I have learned basics of python only. What are the apps that use database that are upto my level of programming?
I am planning to use django...
I want to find difference between two list. I came across sth called list comprehension. I can't tell you how confused I am with this.
# Python 3 code to demonstrate
# to remove elements present in other list
# using list comprehension
# initializing list1
list1 = [1, 3, 4, 6, 7]
#...
def find_next_square(sq):
# Return the next square if sq is a square, -1 otherwise
sq2=(sq**1/2)
xyz=isinstance(sq2, int)
if (xyz==True):
print("Is perfect square")
nextsq=sq+1
print("Next perfect square=",nextsq**2)
else:
print("Not...
def find_next_square(sq):
# Return the next square if sq is a square, -1 otherwise
sq2=(sq**1/2)
xyz=isinstance(sq2, int)
if (xyz==True):
print("Is perfect square")
nextsq=sq+1
print("Next perfect square=",nextsq**2)
else:
print("Not perfect...
Here is the code that I am talking about-:
n=int(input("Enter a number"))
for num in range(2,n+1):
for i in range(2,num):
if(num%i==0):
break
else:
print(num,end="")
If I give n=5 output should be 2,3,5.
Here is my dry run. Everything is fine except for 2...
I am learning to code and 1 thing that surprises me is how do I internalize all the code? I understand the code. I know the algorithm as well. But I want to be able to solve any types of problems(related ones) after learning 1 code. How do I become able to do that? So for that I am first trying...
I am learning to code and 1 thing that surprises me is how do I internalize all the code? I understand the code. I know the algorithm as well. But I want to be able to solve any types of problems(related ones) after learning 1 code. How do I become able to do that? So for that I am first trying...
I am learning absolute basic python from udemy course. Till now I see no improvements at all. Except some small small improvements. How should I approach to learn python? I have 0 basics of programming even though I had already studied C and C++ as well as data structures and algorithm. I...
I found this article about Alan Turing and his concept of Turing machines on the AMS website. Since we often get questions about countability and computability I thought it is worth sharing.
https://blogs.ams.org/featurecolumn/2021/12/01/alan-turing-computable-numbers/
It also contains a Python...
Here's what I've done:
Mentor note: replaced icode tags with code=python and \code pair.
def valid_braces_placement(s, L):
if len(L)==0:
return False
string = ''
for element in L:
string = string + str(element)
D = ['+','-','*']
return...
I have been using Visual Studio Code for a couple months now and it has been fine. When I want to run some code, there is usually a little green triangle button in the top right corner that I can click on. A few days ago, that triangle turned white only for Python files (it is still green for...
str1="hello"
for stringElement in str1:
print("str1","=",stringElement)
Strings are arrays in python and they are represented like this.
Now I want to understand how the for loop is working here.
My dry run-:
for h in str1
print h
for e in str1
print e
and so on till...
(I Didn't use code formatting here as I felt it was not necessary)
I have read multiple textbooks, articles and watched multiple videos about name binding in python.
Till now what I understand can be summarized in this-:
x=1 means name x is binded to object "1"
z=x and we know x=1
=> z=1
so...
(I Didn't use code formatting here as I felt it was not necessary)
I have read multiple textbooks, articles and watched multiple videos about name binding in python.
Till now what I understand can be summarized in this-:
x=1 means name x is binded to object "1"
z=x and we know x=1
=> z=1
so...
1) Basic python only no data science or machine learning or game development.
2) I have CS experience and some programming experience but I am really bad programmer, so you can discount my programming experience. But I can learn cs concepts on the go.
3) Contains lots of solved and unsolved...
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...
I need to calculate H-bonds in a specific direction of a C-alpha atom of a protein. And, I need to calculate that from a PDB file.
Can anyone give me a general guideline/direction/idea regarding how to do that?
N.B. I need to write a python program.
Hello, I am learning trying to set up a code that searches for a certain pattern in the text by implementing Rabin-Karp Algorithm.
When setting up the Rabin Karp hash function, I have been told that I should set a value q in order to lower the time complexity of the function, and that q should...
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...
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...
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...
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...