I am curious about the complexity of:- a function that multiply input by 5 (n*5) a function that add 5 to the input (n+5) in (3) is the time complexity o(3**n)? Answer Strangely enough, O(func(n)) is just func(n). Why? The only real think your code can do is add 1. So whatever result it go, it got there by ca…
Tag: python-3.x
count consecutive vowels in words
So, this is what I have so far to find vowels in each word in the text file. It doesn’t work, and I still need to be able to count how many consecutive vowels are in the words. If you can help, but make it to the level of simplicity I have done so far, that’d be great help. Lmk
Use lambda with multi input with numpy.apply_along_axis
Here is my code: But the above way will give me error, missing 2 required positional arguments. I have tried to do like this: It works but every time when I need to do computation on the array element, I need to type the index, it is quite redundant. Is there any way that I can pass the array axis
How is print(‘r’) or print(‘ ‘) giving me the output?
We were asked to print the following output: I understand that it would require two loops so I tired this: With this I am getting the desired output, but as soon as I remove the last line of print(‘r’) the output becomes something like this: The desired output also comes out when I used print(R…
Obtain a list of all combinations of two elements with length n [duplicate]
This question already has answers here: How can I get “permutations with repetitions/replacement” from a list (Cartesian product of a list with itself)? (6 answers) Closed 5 days ago. I have a list of two items: L = [(0), (1)] I would like to obtain a list of lists containing all possible combinat…
Pop or Delete a Dictionary item from list
I have this list of dictionary items. I want to delete a specific dictionary entry from the list by comparing it with a dictionary item I have a variable I would like to do, To get, Answer It seems that you are trying to delete a tuple of items. Your to_delete is actually a tuple of dictionaries, so to delete
Python: get crypto pair prices from Binance API, loop pairs from file
I’m trying to get prices of crypto pairs that are on text file. The pairs are written only one pair by line, so every new line has one pair. my code is: When i run this code only first pair in file is printed and then I get a lot of errors from Binance client.py, the last error is: APIError(code=-1100):
Unable to fetch tabular content from a site using requests
I’m trying to fetch tabular content from a webpage using the requests module. After navigating to that webpage, when I manually type 0466425389 right next to Company number and hit the search button, the table is produced accordingly. However, when I mimic the same using requests, I get the following re…
Selenium with Python not able to fully open the website
I have tried the following code and tried to open the website as mentioned: The website opens with the Chrome Browser but not with the Selenium using Python. Please let me know what should I do to open the website completely. Answer You can run it with chrome options. I am able to launch your application with…
Automatically change variable coming into function to string
Is there a way to automatically change the type of a variable when it arrives at a function, eg: I know this code won’t work, but it’s just to explain my question. I also know I can just do x = my_func(str(x)), but I specifically want to make sure all variables coming into function will be string.…