I found this fantasy name generator here. I am trying to adapt the code to suit my purpose. I want to create an NPC name automatically, using the function name_gen within the class NPC. With the NPC characteristics being: The code from the name generator I need is the following: Now the only thing I think I s…
Tag: python
How to get the list of students with second lowest grade?
I am trying to solve a problem in coding websites. I came up with below problem. Problem: Given the names and grades for each student in a class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the second…
Pandas: using groupby to calculate a ratio by specific values
Hi I have a dataframe that looks like this: and I want to calculate a ratio in the column ‘count_number’, based on the values in the column ‘tone’ by this formula: [‘blue’+’grey’]/’red’ per each unite combination of ‘participant_id’, R…
Python: Image face detection and sorting into face and no face
I am trying to create a sorting system where an image is sorted based on having a face or not. and it doesn’t seem to run quite as expected. after the first image is sorted, the loop stops working and I can’t seem to figure out what is wrong. (I am aware of how inefficient it is). all in all,
Signature does not match – POST HTTP Request to BingX API with Python
I’m trying to communicate with an API of a Tradingplatform via post requests in Python. Unfortunately, this only works if the request does not have to be signed. At the beginning I just wanted to follow the example of the documentation (BingX API Documentation on GitHub) to get an account balance. The e…
Selenium element is not attached to the page document
I am trying to scrape this particular site with Python: https://www.milanofinanza.it/quotazioni/ricerca/listino-completo-2ae?refresh_cens. I need to get all the isin codes and the names. My idea was to get them all in 2 separated lists, to do that I try to get the entire column (by changing the Xpath to tr ra…
I’m having trouble writing the ADFGVX cipher in python
First of all, if anyone doesn’t know how the ADFGVX Cipher works, Here is a video on it: https://www.youtube.com/watch?v=T0xfKiU9Rr4&t=11s Assuming you now know how the cipher works, let’s look at my problem now: First, we need to create the Polybius Square. I did this by creating a table: Nex…
How to create a frequency table of each subject from a given timetable using pandas?
This is a time table, columns=hour, rows=weekday, data=subject [weekday x hour] How do you generate a pandas.Dataframe where, rows=weekday, columns=subject, data = subject frequency in the corresponding weekday? Required table: [weekday x subject] Answer Use melt to flatten your dataframe then pivot_table to …
Clear reactions in setting time [nextcord.py]
I want clear or disable reactions in setting time using nextcord.py I making poll command and wanna delete or disable(I dont know can I or not) reactions in setting time I have code like this I have my time time_plus and wanna do something when time invoke Answer You can use reaction.clear or reaction.remove …
How would I perform an operation on each element in an array and add the new value to a new array in Python?
I have an array of ten random values generated using Numpy. I want to perform an operation on each element in the array by looping over all ten elements and then add the result of each to a new array. The first part of looping over the array but I am stuck on how to add the result to a