Skip to content

Tag: python

Is it possible to do a binary search on an unordered list

Is it possible to do a binary search on an unordered list, and if so, what would the code look like? Thank you very much for the help. Answer Read this Binary Search. In the second line it says “…is a search algorithm that finds the position of a target value within a sorted array.” If we ha…

Printing issues when moving from Python 2 to 3 with code

I have a code that I am trying to convert but it’s written in Python 2 and I would like to print this code in Python 3. However, it’s not able to print in matrix format. I am getting output in an unrecognizable table format. The code is following: The expected output is in the following format: Co…

How to setup ffmpeg in docker container

I want to compress the video from project directory using ffmpeg in python the video is saved from cv2.VideoCapture(rtsp_url) Normally it run without problem in my local machine, but when I dockerize my app it seems docker container can’t recognize ffmpeg or I missed something. It throws exception This …

Python + pdfkit: Generate stream with pdfkit

I’m trying to use pdfkit to turn html pages into PDFs, and then return a stream of that PDF as this code is a Flask API called by a webpage. As far as I can tell, when you use pdfkit.from_file, you have provide both an input and output path: The problem is, I don’t want to write these files to

python nested dictionaries from sql queries

Hello i am trying to create a dictionary that would like this I have the following in a db which i am querying i have the following code in order to loop through the query results and create a dictionary but its not creating it like the i am wanting it o Any help would be very much appreciated. Answer

Discord bot with pre-defined tags

I have a problem. I have a list of programming languages, for example The user should be assigned a maximum of three programming languages as roles. Is there a possibility to use a tag input like for web pages in Discord? For example, the user just writes Ja and the user gets back Java and JavaScript and can …