238 Answered Questions for the topic Python
Python Programming Logic Question
A cookie recipe calls for the following ingredients:• 1.5 cups of sugar• 1 cup of butter• 2.75 cups of flourThe recipe produces 48 cookies with this amount of ingredients. Write a programthat asks... more
How do you open a file over the network at a specified URL?
I tried urllib and urllib.request but not able to get the answer
What function could you use to create a complete copy of a nested dictionary (a dictionary that has dictionaries as values)?
I've tried many answers such as "dict" "copy" "deepcopy" but can't seem to find the answer for the copy of nested dictionaries
Python: using a while loop to parse multiple pages
Using the URL inside the function at the bottom of the code, I want to parse all of the quotes that are listed in all of the pages. However, this code only returns the first page's quotes and gives... more
Need help writing python code to look at 3 things from an excel data file.
I need help with writing some codes for my project using Python. This is a very intro level class as I am an english major but took this class as interested in biostats (micro is my minor). We are... more
How does one set about learning how to use a python3 module
I have recently started to learn python and i have fine understanding of the python 3 syntax. I wanted to start learning more about numpy ,scipy tenserflow. I have tried reading the documentation... more
How to write a and b as inclusive integers? (python3)
Write a program that takes three integers a, b, and k as command-line arguments writes the integers between a and b (both inclusive), but only k integers per row.I honestly have no idea where to... more
how do you check if the starting value of a file is "S" if: content = file.read() first = content last = content[-1]
Pcregrep vs Perl vs Python for bash scripting when needing advanced regex features?
I've lately been using `pcregrep` to do Perl-style group matching when doing my bash scripts.The problem with `pcregrep` is that it's not readily available on Linux machines in general.An... more
How to integrate without limits in SymPy?
I am given `p(x) = 2ax^2 - b` and asked to integrate it twice, but I'm not given limits. However, when I just use `integrate`, I'm not given a constant of integration, which is crucial to the next... more
load .mat file in simulink from python hdf5storage library?
I am trying to load/read some random data in simulink I created using the Python module `hdf5storage`. I created `.mat` file in Python (simulink supports version 7.3 only) using this code: #... more
Implicit differentiation with Python 3?
How can we derivate a implicit equation in Python 3? Example `x^2+y^2=25` differentiation is: `dy/dx=-x/y`, when try this: from sympy import * init_printing(use_unicode=True) x =... more
Python/matplotlib : plotting a 3d cube, a sphere and a vector?
I search how to plot something with less instruction as possible with matplotlib but I don't find any help for this in the documentation. I want to plot the following things: - a wireframe cube... more
Python partial derivatives easy?
I'm interested in computing partial derivatives in Python. I've seen functions which compute derivatives for single variable functions, but not others. It would be great to find something that did... more
Calculating the overlap distance of two 1D line segments?
Trying to build a function that will return the total overlapping distance between 2 line segments, denoted by start and end ints. Currently I have this: That I got off the internet... more
How to execute raw SQL in SQLAlchemy-flask app?
How do you execute raw SQL in SQLAlchemy? I have a python web app that runs on flask and interfaces to the database through SQLAlchemy. I need a way to run the raw SQL. The query involves... more
Use python to calculate a special limit?
I want to calculate this expression: (1 + 1 / math.inf) ** math.inf, which should evaluates to e. However Python returns 1. Why is that? =====UPDATE======== What I want to do here is to... more
Python Tkinter: Attempt to get widget size?
I am trying to find the size of my window by using the `winfo_geometry()` function but it ends up returning `1x1+0+0` I have also tried `winfo_height, winfo_width` but i keep getting `1` ### CODE... more
How to perform OR condition in django queryset?
I want to write a Django query equivalent to this SQL query: SELECT * from user where income >= 5000 or income is NULL. How to construct the Django queryset filter? ... more
Matlab - Iterating through an array and appending to a new one?
I got an array that is a audio recording, and I'd like to add some noise on it so later I can remove it in Simulink and compare the original to the one that I removed the noise. My problem is that... more
What's the best way to calculate a 3D (or n-D) centroid?
As part of a project at work I have to calculate the centroid of a set of points in 3D space. Right now I'm doing it in a way that seems simple but naive -- by taking the average of each set of... more
How to efficiently determine if a set of points contains two that are close?
I need to determine if a set of points (each given by a tuple of floats, each of which is in [0, 1]) contains two that are within some threshold, say 0.01, of each other. I should also mention that... more
I would like to be able to compare values in one CSV with a nominal set of values in another?
I have been given the task of injecting faults into a system and finding deviations from a norm. These deviations will serve as the failures of the system. So far we've had to detect these faults... more