Categories
Mastering Development

Maybe my PyCharm is not properly configured? Or is my code wrong? [closed]

Consider the code below: from tkinter import * import random tk = Tk() canvas = Canvas(tk, width=400, height=400) canvas.pack() def random_rectangle(width, height, fill_color): x1 = random.randrange(width) y1 = random.randrange(height) x2 = random.randrange(x1 + random.randrange(width)) y2 = random.randrange(y1 + random.randrange(height)) canvas.create_rectangle(x1, y1, x2, y2, fill=fill_color) random_rectangle(400, 400, “green”) Now, I am using PyCharm Community to run […]

Categories
Mastering Development

Combining parts of a list inside a list

Given a list like: [[‘james’,100,200,300],[‘james’,200,300,400], [‘charles’,200,200,100]] I need to add the components of the two lists that have the same first index like so: [[‘james’,300,500,700],[‘charles’,200,200,100]] Thanks for the answers. Just found out I have to do so without importing any modules. Is there a way to do so? I’ve tried using for-loops but cannot find […]

Categories
CMS Mastering Development Wordpress

(BAD REQUEST) 400 admin-ajax.php error WordPress

I updated my WordPress to current version as it was very outdated. And now I am getting a bad request browse issue now. /wp-admin/admin-ajax.php:1 Failed to load resource: the server responded with a status of 400 (Bad Request) browser pop up. This only occurs when user is not logged in admin. I checked plugins and […]

Categories
Mastering Development

How to program a collision

I want to code a collision. I have 2 classes and if they collide one of them should undraw for 1 second #Laden der Pygame Bibliothek import pygame import time import random #Initialisierung der Pygame Bibliothek pygame.init() # Spiel-Fenster erstellen size = [700, 500] screen = pygame.display.set_mode(size) screen.fill((255,255,255)) # Noetig um die fps zu begrenzen […]

Categories
CMS Magento Mastering Development

Magento 2: Set custom response status code for REST API

I have created a REST API using Magento 2.3.2 CE All went well, but now I want to return custom HTTP Status Code with my error message like 401 Unauthorized, 409, 400, etc. Currently, for all my API calls, I am getting HTTP Status Code 200 I need to pass custom response codes, how can […]

Categories
Ask Mathematics

What weights should I buy for my gym? (a case of integer partitioning)

I am trying to solve for possible combinations of weights that would be appropriate for use in my home gym. I have been told that this is a case of integer partitioning, but I am not sure how to solve it and would appreciate some guidance (or even better a solution!). Given that I am […]

Categories
Mastering Development

Missing leading hour zero on my digital clock

I tried to add the zero in front of the hour if hour is less than 12, but it only works on the minutes and seconds. I was not taught ternary yet so I can’t use that as an option in my code. I tried everything I could think of without using a ternary. I […]

Categories
Mastering Development

Maximize profit with disregard to number of pickup-delivery done OR tools

I am trying to maximize profit, whether I deliver all pickups-deliveries does not matter. I tried setting SetArcCostEvaluatorOfAllVehicles to use negative profit instead of cost callback; however, this does not work, an I get no solution often, my thought is that cost cannot be negative. Is this correct? Adding AddVariableMaximizedByFinalizer with profit callback does not […]

Categories
Mastering Development

Regex – Prioritize grouped match

I’m looking at code for a Twitch bot someone wrote, and they have this regex: ([_-])?(left|right|a|start|\.){1}(\d*)(\%?)(\d*)(ms|s)?(\+?) This bot parses text to press inputs on a Twitch Plays stream. Whitespace is trimmed before parsing, An example of a full input is _a800ms. The second group is generated based on the available inputs for the console, so […]

Categories
Mastering Development

Python novice! I need a button to change text in PyQt5. :(

Absolute beginner here, have no idea what I am doing wrong. All I want to do here is have the pushButton in PyQt5 to change to “Working…” and Red when clicked… which it currently does. Thing is I need it to also change back to the default “SCAN” and Green color when done running that […]