So I’m coding a test platform consisting of Multiple Choice Questions ( MCQs ) in Django. Everything is working fine but somehow I think that the radio button value from my question page is not getting fetch via POST request. Would appreciate some help! Here are my models : Here are my views : Here̵…
Tag: python
Assigning color to ttk.Button
I would like to assign color to the background of my button as well as the text of my button. I thought I could assign it with fg and bg but there seems to be no reference at all in ttk.Button. How can I assign text and background color to my button? Error when calling style Answer Python docs explain
SymPy returns wrong solution of a nonlinear ODE?
I am trying to solve the ODE of the frictional free fall: I think the solution might be wrong. I believe it should be the reciprocal of the returned expression. Therefore, if I try to find the value of the constant for an initial condition of rest (v(0) = 0), I get no real solutions: As a consequence, if I
How fulfil empy df by FOR loop
I need to create a dataframe with two columns: variable, function based on this variable. There is an error in case of next code: What do I need to fix here? Looks like answer is easy, however it is uneasy to find it… Many thanks for your help Answer I like Vaishali’s way of approaching it. If you…
How to take n block of a 3d array in python?
I had 328 grayscale images with the size 128*128 and I convert all of them into a 3D array with the shape (128,128,328). Now I want to convert it into 5 separated 3d arrays with the shape of (128,128,64) without changing in sequence. As you can see 328 is not divisible by 64 and using dsplit function is not w…
Python – Run multiple async functions simultaneously
I’m essentially making a pinger, that makes has a 2d list, of key / webhook pairs, and after pinging a key, send the response to a webhook the 2d list goes as follows: My program is essentially a loop, and I’m not too sure how I can rotate the some_list data, in the function. Here’s a little…
Find all values that one column’s value has and collect as JSON
class_id class code id 8 XYZ A 1 8 XYZ B 2 9 ABC C 3 I have a dataframe like above. I want to transform it so the ‘codes’ column below collects all the unique (code, id) pairs into a JSON format that a class contains. class_id class codes 8 XYZ [{‘code: ‘A’, ‘id’: 1},…
How to remove duplicates in a list of tuples
I have a list of tuples: So when the first item of the tuples in the list is double or more, i want to remove the duplicates. The end result has to be the wantedList. In a normal list i can do the “make a dictionary” trick but i dont know how to solve it with a list of tuples.
How to send a complete email using smtplib python
I am trying to send an email using Python smtplib. My objective is to include the below info in email Attachment file #works fine Paste the contents of a table in message body #works fine Write a few lines about the table (as text) in message body # not works. instead stores as an attachment So, I tried the b…
Flask returns 404 error when trying to connect via localhost
I am trying to build a Python Flask application, but I cannot access it. Flask recognizes the request, but for some reason doesn’t execute the function. Here is my code: I am currently running it by typing flask run the Windows CMD. The GET request is detected, but main_page is not called and 404 is ret…