Questions tagged as 'python-3.x'

1
answer

Syntax of the Lambda function

I'm pretty early in the Lambda function study and I'm pretty lost. I know the code could only be done with the "sum" function but I want to learn the Lambda syntax. a = [] for b in range(0, 4): c = int(input()) a.append(c) d = (lambda...
asked by 19.02.2018 / 04:36
2
answers

limit the number of digits Entry - Tkinter

Hello. How do I limit the number of digits I can put in a Entry of module Tkinter ? from tkinter import * root = Tk() entrada = Entry(root) #Quero limitar para que nesse entry, possa colocar apenas 8 digitos entrada.pack()...
asked by 10.10.2018 / 00:21
1
answer

String with the largest and smallest number of characters

I want to return the largest and smallest string . See: nl=str(input('Digite uma string')) String=[] string.append(nl) while caractere != 'pare': caractere = str(input("Digite uma letra ou número ")) string.append(caractere) A...
asked by 06.03.2018 / 00:59
1
answer

How to check the existence of a file and the amount of lines written in Python?

What is the best way to check if the file exists and the number of lines within the file.     
asked by 23.01.2018 / 13:11
2
answers

Is there any command to terminate the program in Python?

For example, I'm writing a code def soma(): n1=int(input('digite um numero')) n2=int(input('digite outro')) soma = n1+n2 print('A soma de {} e {} é {}'.format(n1,n2,soma)) #começo do programa p=input('Você deseja somar?') if p=='sim...
asked by 05.03.2018 / 13:25
2
answers

Ignore any white space in the middle of a string

I'm trying to create a regex that is able to find a string in a text even though there is some white space in the middle of the words. For example, I search the text for the following excerpts "impaired conciliation" or even "irreconcilable"...
asked by 30.01.2018 / 16:29
2
answers

Adding points in a range of known data

I'm working on data analysis using Python and for this I'm training algorithms like SVC and K-means. The data used for the training have a fixed spacing between each sample, since they are sampled by an oscilloscope in fixed periods of time, in...
asked by 19.02.2018 / 20:05
1
answer

For i uses only the last variable - Python

Good morning! I have a project that I am improving and would like to do a For i to run all the variables within the project, however when running it applies the project only to the last variable. Code: for i in ['1', '2', '3']: a...
asked by 26.04.2018 / 15:20
1
answer

Custom function for the function sorted in python 3.x

In python 2.x I can pass a custom function to sorted function, how to do this in python 3.x? Basically convert the code below def numeric_compare(x, y): return x - y print(sorted([5, 2, 4, 1, 3], cmp=numeric_compare) )     
asked by 02.01.2018 / 02:40
2
answers

Error in decoding in request

I am sending the second string via post (JavaScript) to my bootle server (Python): query = { 'wiki': 'Tr%E1%BA%A7n_H%C6%B0ng_%C4%90%E1%BA%A1o', 'uid':'f17afd66aae3a' } $.post(url, query, function(data, status){}): But when I print what I g...
asked by 05.09.2018 / 19:36