python

Python. Finding a short path in a graph

Let's say there is a graph. As a result, I write it down in the dictionary and it comes out like this, for example: {0: {1, 3 ... not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None

How to determine the complexity of the sorting algorithm?

There is a sorting algorithm: def search(a): if len(a) < 2: return a pivot = a[0] left = [int(i) for i ... t] return search(left) + [pivot] + search(right) I want to determine its complexity, can you tell me how to do it?

Development of Discord bots on discord.py

I'm writing a function that changes the channel name when someone leaves or comes to the server. It outputs the number of ser ... ков: {}".format(len(member.guild.members)) ) What is the problem? Maybe this is because my computer is slowing down?

Unity and Python scripts

I have a question! Is it possible to somehow write scripts for the game on Unity? If so, how?

How do I get the volume from the microphone in decibels in real time?

I would like to know if there is any library for python or c# that would allow streaming to measure the decibel level of inco ... d the microphone? For example: A person speaks into a microphone and I need to measure its volume in decibels through a code.

The if else construct doesn't work in Python

So, there is such a construction if else: if int(first_player): random_number = random.randint(1, 3) print(random_n ... the string can't be converted to digits? If not, how should the type of input values be checked? IDE - Pycharm Python - 3.8

Python JSON parse all data by the views key

Wikipedia Statistics How to get a list of all "views", numbers like: 16944,15420....

bs4 parsing of specific rows from an HTML table

I ask for help, here from the table of this type: <h1>Modems</h1> <a href="..">zurück</a> <b ... you understand the cumbersomeness of this code. Does bs4 or other python tools have something more concise and more adequate?

Parsing fl.ru using python (bs4, requests), how to separate categories when parsing?

I start parsing orders on in this way: import requests from bs4 import BeautifulSoup as BS r = requests.get('https://www.fl ... }) print(orders) Save() Help me figure out how to parse only orders from a certain category (texts, design, etc.)?

Color text in python

How to output multicolored text in python 3.8

How to get the full path to a file with multiple python os attachments

There is a folder structure: главная папка ----вложенная папка --------третьего уровня ------------файл ------------файл --- ... h.dirname(i) # Не отрабатывает In general, it is not possible to get the parent folder of the destination files in any way

How random is random.randint in python?

import random x=0 for i in range(10000): my_series = [random.randint(0, 11) for i in range(100)] x += 1 if len(list(f ... negative even though the list generation is random and the possible number of even and odd values is the same(from 0 to 11).

Output of a TIME string from sql in python

Trying to output a table via python def verification(): connection = DataBase.getConnection_log() try: ... | time | YES | | NULL | | +--------------------+--------------+------+-----+---------+-------+

Coordinate-based descent method in Python

There is a function def f(x, y): return (5 * (1 - x)) / (7.88 * (1 - y)) For the one-dimensional optimization problem, I u ... n value is minimal. x, y from the segment [0.0001, 0.9999] Can you give an example of how this is implemented in a human way?

Small delay between functions | Python

I'm trying to prescribe the functionality of an ordinary smartphone, including itself, using Tkinter. First of all, I decided ... _sprite = self.screen.create_image(98,165, image=theme) self.screen.image = theme IPhone = Smartphone() root.mainloop()

TypeError error: 'float' object cannot be interpreted as an integer in range

I don't understand something. Here I just want to derive the root from a (code below): def root(a): s=() for i in ra ... bject cannot be interpreted as an integer Why does this exception occur, and how do I fix the error? Thank you in advance!

Python's return function

Hello everyone I have a code that runs over a range of strings, while throwing out None. If you don't use return and def, the ... e function into the "global" code, i.e. outside of it? Thank you all in advance! P.S. It is also necessary to filter out None

How to pass arguments from function to function in Python

Thought that I was doing something wrong by passing arguments through a function to another function. Example: def foo(): ... the argument from foo () to log() via bar ()? There is an option via global variables, but how correct is it in this option.

How do I remove all spaces from a string in Python?

I googled the strip() function, but it only removes the first and last spaces, and I need everything. For example, if a = ' s ... fsfs', then you need to get a = 'sddfsdfdfsfs'. Is there such a function or is it necessary to do something through the loop?

Entry widget in Tkinter

Good day to all. Recently started programming, in python quite lamer. I want to write a desktop chat with the client and serv ... ORT = int(PORT) BUFSIZ = 1024 ADDR = (HOST, PORT) client_socket = socket(AF_INET, SOCK_STREAM) client_socket.connect(ADDR)