Questions tagged as 'python'

3
answers

How could I improve the code?

Is there any way to improve this code? lista = [0,0,0,0,0] acuNota = 0 x = 0 arq = open("notas","w") while x <= 4: lista[x]= float(input("Insira uma nota por favor!")) acuNota = acuNota + lista[x] print ("Criando arquivo e...
asked by 07.08.2015 / 15:36
2
answers

Problem using Switch Case in Python 3

print ("ESCOLHA A CERVEJA PELO NUMERO") print ("1-ANTARTICA R$6.00;2-SKOL R$6.50;3-BRAHMA R$8.20;4-SOL R$8.25;") cerveja = input ("5-NORTENHA R$16.80;6-PROIBIDA R$4.80;7-DEVASSA R$5.90;8-HEINEKEN R$9.00") q = float(input("Quantas ???")) def cas...
asked by 26.10.2015 / 05:30
2
answers

Mapping algorithm complexity

Could you tell me the algorithmic complexity of this code, in particular, how complex is the function map numero = map(lambda x: x[0], lista) map(lambda x: (numero.count(x)), sorted(set(numero)))     
asked by 19.04.2016 / 20:17
2
answers

How to print text in the same line in Python

list = open("list.txt", "w") list = list.readlines() for i in list: print i I wanted to print i on the same line without getting down, type replacing the current word     
asked by 26.05.2017 / 20:14
2
answers

How to break the line?

Nome = input("Digite o nome do cliente: ") DiaVencimento = input("Digite o dia de vencimento: ") MêsVencimento = input("Digite o mês de vencimento: ") ValorFatura = input("Digite o valor da fatura: ") print("Olá,", Nome, "A sua fatura com venci...
asked by 26.04.2017 / 20:44
3
answers

if and else with almost equal blocks

In Python, suppose I have a function: def func(x): if x%2 == 0: j = x/2 print(j) else: j = x print(j) Do not mind the logic of the code, it's just a simple example. The blocks of if and else are...
asked by 02.05.2018 / 05:12
5
answers

Beginner in Python, else, and elif

idade = int(input("Insira sua idade:")) if(idade<=0): print("Sua idade nao pode ser 0 ou menos de zero") elif(idade>150): print("sua idade nao pode ser maior de 150 anos") elif(idade<18): print("voce precisa ter mais de 18 a...
asked by 18.01.2017 / 22:14
2
answers

In Python, is there any way beyond 'numpy' and 'float (' nan ')' to get the special constant 'nan'?

I've been reading the Underhanded C Contest site, where the goal is to write subtly malicious code that looks normal the first View. One of the common techniques mentioned was the use of not a number , or nan , which has some special pr...
asked by 26.11.2018 / 19:32
3
answers

I want to change a string in 3 positions

I would like to walk 3 positions with a letter from a string , for example, make the letter A turn D, I tried the second command: texto[c] = texto[c] + 3 But it still does not work, what would be the right way to do it?     
asked by 08.11.2017 / 20:45
3
answers

Catching more items in a list array in Python

I have an array in Python made up of arrays. But these arrays can have different sizes. For example: matriz = [[1,2,3],[4,5,6,7],[1,2,3,4,5,6]] What I want to know is if there is a medium (some python-ready function) that returns the size o...
asked by 07.12.2016 / 14:51