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…
Tag: python
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…
python program won’t handle systemd KillSignal at reboot
I have a set of LEDs that I start and turn into a specific colour when the machine starts up and during other events. At power-off/reboot I want the LEDs to reset to the default colour. To achieve this I start a systemd service that starts up the LED code and have a handle for the signal in the python
How to convert time stamp in Python from dd/mm/yy hh:mm:ss:msmsms to yyyy-mm-dd hh:mm:ss:msmsmsmsmsms
I have created an automated data client that pulls data from a txt file and inputs it into a csv file. Each data entry contains a timestamp, but it is not in the format I need it in, I need it to match the datetime.now() format: ORIGINAL FORMAT [03/11/22 01:06:09:190] DESIRED FORMAT 2022-11-03 01:06:09.190000…
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 …
Creating sets of specific extracted values from a .txt file (Python)
I have a .txt file that says “NAMES,” “POINTS” and “SUMMARY” in capital letters, each followed by lines containing data. Each of these three groups is separated by an empty line: My goal is to create three separate sets of names, points and summary. I already created a set …
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
How do I search a SQL List inside of python to check if the username matches a user input?
So I am making a login page, and I need to compare the username of an SQL list to the user input. I will also use the answer for the password. This is what I have tried and it returns false. The list_of_users is there to simulate what the SQL gives when you do cursor.fetchall() on an SQL database. Any
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 …