Questions tagged as 'python'

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

How to transform str into int?

I tried to make the score into int as I did in JavaScript but it did not work: placar = "0 x 0" print(int(placar)) I expected it to show 0 but resulted in an error, how do I turn the scoreboard into int ?     
asked by 31.10.2017 / 20:58
2
answers

How to stop a run in Python? [duplicate]

I'm starting to program in Python and would like to know how do I stop running the program? In language C for example, there is the equivalent command system("pause") . If I open the IDLE, more specifically the Python shell the progra...
asked by 08.04.2017 / 18:18
3
answers

How to separate a digit from an integer?

For example, for the program say the house number of hundreds of a number from: número_int = int(input("Digite um número inteiro: "))     
asked by 26.04.2017 / 21:27
3
answers

How to create an array in python

I want to create an array where the user specifies the number of rows and the number of columns. Initially an empty matrix was given: matrix = [] The codes should the code below was my attempt: def gerar_matriz (n_linhas, n_colunas): '...
asked by 18.05.2017 / 01:22
2
answers

How to loop until the rows of a given .txt file run out

I would like to make a basic loop system for example, open the file that the user typed after using an if for as long as you have lines in the file to loop with other codes     
asked by 27.04.2017 / 02:49
3
answers

How do I get the largest value from an array / vector in python?

How do I get the highest value from an array or vector? For example, in this exercise I have to do a 4x4 array and return the row and column of the largest element , but I stopped there. m = [] for i in range(4): linha = [] for j i...
asked by 24.05.2017 / 17:15
2
answers

Regular expression (regex) for links in web pages using Python

I'm trying to learn how to create a webcrawler. Part of the code will be to extract links on a web page (links beginning with http or https): import re urls = re.findall(r'href=[\'"]?([^\'" >]+)', s) How can I modify or create a new r...
asked by 31.07.2016 / 18:57
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