Questions tagged as 'python'

2
answers

Theoretical question about while and indentation

count = 0 while (count < 10): # Ponto A print ("Olá...", count) count = count + 1 # Ponto B # Ponto C Why    count < 10 is always true at point B. is not true if "Point B" belongs to the same indentation of "Point...
asked by 09.06.2017 / 14:27
2
answers

Logical operations in Python 2.7

When performing logical operations in Python 2.7, I noticed something strange. For example, doing 5 and 6 results in 6 . Now, the correct one would be 4, since converting these values to binary, we have 101 and 110 , wh...
asked by 21.06.2017 / 15:17
2
answers

Sort algorithm is not working!

"" " Sort the elements of a list in ascending order "" " #ordenação bolha #L = [5,3,1,2,4] L = [7,4,3,12,8] x = 0 while x < (len(L) -1): if L[x] > L[x+1]: L[x],L[x+1] = L[x+1],L[x] x += 1 print(L) Output: [4, 3, 7, 8, 12]...
asked by 25.03.2018 / 19:24
2
answers

Replace all characters in a string with another character

def getGuessedWord(secretWord, lettersGuessed): secretWord_copy = "" for i in secretWord: print(i) secretWord_copy = secretWord.replace(i," _ ") print(secretWord_copy) secretWord = 'apple' I'm trying to replace ev...
asked by 22.04.2018 / 21:04
1
answer

Program to convert mp3 using multiprocessing module is looping

import subprocess from multiprocessing import Process, Lock def ConverteMusica(a,lock): input_file_fmt = '{}.mp3' output_file_fmt = a for x in range(1, 5): subprocess.call(['ffmpeg', '-i',...
asked by 10.04.2018 / 14:43
2
answers

Get Data in JSON structure with python

I want to access certain information in the JSON code below, with python: { "informacao1": valor_informação1, "informacao2": "{ dado=informação_dado }" print(arquivojson.get("informacao1")) The above print will display the line bel...
asked by 21.05.2017 / 16:42
2
answers

Regex to get text into python?

I would like to extract the text contained between < > of a string. At first, I built the following expression: import re m=re.search(r'<(.*)>','abevbv envvrhwkv <eiwbv> ebvi <wieunv> ajhbsvhj') The expression would...
asked by 30.04.2017 / 19:10
2
answers

Deleting rows only if any cell in the worksheet is blank (using a script)

I have a calc (libreoffice) / Excel spreadsheet (it's actually a text file I opened as a spreadsheet for easy viewing) that contains some blank cells (not the entire line): I would like if some cell on the right is blank, the entire row...
asked by 28.05.2017 / 17:04
3
answers

Doubt with IF and LISTS python3

I am new to the python language, but I started developing a script to manage linux servers etc ... I have a problem with a snippet of code: def rotear(): print(" \n Disponível: \n"), os.system("ifconfig|grep eth|cut -c 1-4") interface...
asked by 21.06.2017 / 05:36
3
answers

Dictionary in python

Next, I have a table with words in a language, I will use example to suppose, from Portuguese to English. These words are in a dictionary where the key is the Portuguese word and the value is the English word. Using the dictionary keys in a stri...
asked by 05.10.2017 / 09:25