Questions tagged as 'python'

3
answers

Display only words that have an even number of vowels within a sentence

I need to make this code in which you scroll through a list and print to the user words that have an even number of vowels. Here is the code: frase = ["Foi magnifica a festa ontem."] palavras = 0 vPalavras = 0 vogais = "aeiouAEIOU" # separar...
asked by 29.08.2018 / 21:51
1
answer

What can not be done with f-string that you can do when using .format?

Hello, I would like to know in what cases I need to use the format method instead of f-string because with f-string I can not do it. For example I think it is not possible with f-string to write a formatted number: 'fps: {:.1f}'.format(55.3578...
asked by 16.07.2018 / 04:06
2
answers

Extract and print specific values from an xml using Python

Hello:) I'm trying to capture data from an xml to use in a search using python, however my algorithm is only returned the data of the last tags, eg: xml is in link and inside it, there are three tags containing the data of the parliamentari...
asked by 25.04.2018 / 03:19
2
answers

Change the value of a number in an array without knowing the position (index) in Python

Hello, how do I change the value of a number in an array when I do not know what its index and can there be more than one value to change? For example, if I have the array: [[4,5,3,15,4], [20,17,3,4,56], [5,6,2,90,32], [18,7,1,8,13], [0,20...
asked by 01.04.2018 / 07:49
2
answers

Logic to get the lowest read value of the user

What's wrong with my logic? I can not return the smallest value def menor(size): size = size vet = [0] * size menor = 0 for i in range(size): vet[i] = int(input('Digite os valores: ')) if vet[i] > menor:...
asked by 26.03.2018 / 03:39
1
answer

importing a file containing a function that I wrote: does not see global variable

ConstroiMatriz.py file: """ Escreva uma função que recebe um inteiro m e outro n e com isso constrói uma matriz mxn """ matrix = [] def main(): m = int(input("Digite o número de linhas da matriz: ")) n = int(input("Digite o número de...
asked by 26.03.2018 / 01:06
1
answer

Program to pick up a webpage events

source code here too: link Goal: catch events in% with% Each month, the URL changes only the thin, for example, in April will be: http://www.bhaktiyogapura.com/2018/03/calendario-vaisnava-abril-2018/ As I can not get right on the pa...
asked by 29.03.2018 / 19:26
2
answers

Get CSV list with Python

I have a CSV file with more than 9000 lines. I need to get a list with just one die from each line. An example is as follows: 01/02/19,carlos,casa,rio 03/05/18,luis,carro,maceio 06/04/17,camila,celular,teresina I need to get a list with...
asked by 27.03.2018 / 02:57
1
answer

Approximation of the cosine function using the n first terms of a series

Data x real and n natural, compute an approximation for cos x through n first terms of the following series: cos x = 1/1 - (x**2)/2! + (x**4)/4! - (x**6)/6! + ... + ((-1)**k)*(x**2k)/((2k)!) My attempt to resolve: import math #x =1 #calc...
asked by 23.03.2018 / 18:50
1
answer

Encodings do not work in a file with OpenCV in Python 3

I followed the face detection tutorial using OpenCV and wrote in Python 3. In this file, print is not used. I already know that Python 3 is international, is UTF-8 compatible and does not need encodings. But even so, no accent appeared on...
asked by 18.03.2018 / 15:51