Questions tagged as 'python-3.x'

1
answer

What is the difference between Python versions 3.4, 3.5, 3.6, 3.7? [closed]

I thought Python only upgraded versions 2.7 to maintain compatibility but did not abandon previous versions of 3.x. But he insists on updating versions 3.4, 3.5, 3.6, 3.7 constantly. What do these different 3.x.x versions have to do differently?...
asked by 03.08.2018 / 21:35
3
answers

Count the most popular words

I'm trying to find the number of occurrences of a list of words in a text: from collections import Counter def popularidade (texto, palavras): texto = texto.lower().split() palavras = palavras.lower().split() lista = [] for...
asked by 10.04.2018 / 11:34
2
answers

How to play a list that skips the numbers according to the number entered

Preferably something that explains the answer below (without the spaces) 0 1 4 9 16     
asked by 14.10.2017 / 17:00
2
answers

Program that warns a secret number using bisection search

Create a program that guesses a secret number using bisection search! The user thinks of an integer between 0 (inclusive) and 100 (not inclusive). The computer, using bisection search, gives a hint and the user responds with h (high), l (low)...
asked by 17.04.2018 / 17:19
2
answers

How to implement Fibonacci more efficiently using dictionaries?

A recursive Fibonacci implementation is: def F(n): if n == 0: return 0 elif n == 1: return 1 else: return F(n-1)+F(n-2) The problem is that it is a little inefficient, since, for example, to calculate F (5), we calculate F (3) m...
asked by 22.04.2018 / 13:40
2
answers

If empty statement in function

Is it possible to create a function that ends with an empty if statement and let the code that called this function determine the action of if? Example: def if(): if x>6: x = input("Valor de x") if() print(x) x = input("Valor...
asked by 03.02.2018 / 07:56
2
answers

Returning only the highest value from a Python list

I have the list ['4', '07', '08', '2017', '364', '355673087875675'] and I would like a formula to return the highest value, which in this case would be '355673087875675' , I tried to use max() , but it did not work, I can not...
asked by 24.11.2017 / 13:01
2
answers

Is it possible to loop with a variable jump?

I wonder if it's possible to create a variable jump loop. For example, in the odd cycles the jump would be 2 and in even cycles the cycles would be 4. I tried to do it with the tertiary operator of Python a if True else b , but it does...
asked by 20.10.2014 / 10:16
1
answer

How to create a "trigger" function when a variable changes in value?

Looking at pygame.Surface.get_rect () , I realize that when I change a variable, for example left , pygame recalculates all class variables automatically ( center , right , etc). I'd like to know, how is this done? How c...
asked by 02.10.2018 / 20:57
3
answers

How to transform content from a dictionary file into Python?

Well, I have a file and I'm getting the contents of it and adding it to a variable. The contents of the file and the value of the variable are like this: NAME=Maquina01 ID="MAQ 15478" version=08 I would like to take this content from the va...
asked by 11.12.2018 / 05:03