Questions tagged as 'python'

1
answer

Run fortran code requesting data read on jupyter-notebook with python restart kernel

Jupyter notebook restart when you run a fortran code that requests data entry, as follows: Notethattheavariableshouldbeprovidedsoonafterthef1call.However,anerroroccursandthekernelrestart: Note: The code works fine without the statement...
asked by 17.09.2016 / 14:46
1
answer

How to compare a list of numeric values with another variable in Python

I need to do a function that compares the values of a list with a variable, return the value of the list closest or equal to the value of the variable. ex: The list is list = [1,2,3,7] and variable is v = 2. In this case it returns the value...
asked by 14.02.2018 / 22:25
2
answers

How to relate two lists, getting the value of one through the maximum of the other?

I am stuck in an exercise that asks for an X number of teams participating in a championship. In the later lines the team name and its score are entered. On the way out, the team that scored the most and the average. My current code is: num...
asked by 24.10.2018 / 21:09
2
answers

Formal definition of operations = e ==

What is the formal definition of using = and == in Python? I can identify in the examples when I have to use which, but when I try to identify these operations by a formal definition as (more or less as if it were a mathematical co...
asked by 29.09.2018 / 03:37
3
answers

is not accumulating values in lists

list1 = list () list2 = list () def read and verify ():     "" reads an integer and checks to see if this returns the read integer "" " while True: try: inteiros= int(input("entre com numeros1 ")) inteiros= int(input(...
asked by 20.10.2018 / 20:43
3
answers

Average student error

I developed the following algorithm to calculate student mean: matricula = int (input("Digite a matrícula do Aluno: ")) nota1 = float (input("Digite a primeira nota do aluno: ")) nota2 = float (input("Digite a primeira nota do aluno: ")) no...
asked by 12.10.2018 / 17:34
3
answers

Remove elements from a Python Parameter List

Basically I want to remove elements from a secondary list based on the result of another list. I have two lists: lista_8 = ['', '', 'Preco', '', 'Preco', '', '', 'Preco'] lista_n = ['positivo', 'positivo', 'negativo', 'positivo', 'ne...
asked by 31.10.2018 / 18:39
2
answers

How to assign values to an undefined number of variables in python?

To assign values to multiple variables it is only to follow this structure: a, b, c = 1, 2, 3; This I know, but what if for example I want to store multiple values that came from an input without knowing the amount of values? How do I do that?...
asked by 03.01.2019 / 02:35
2
answers

Problems with input results after using an "int ()"

Code sample: idade = input("Qual a sua idade? ") int(idade) if idade >= 45: print("Tá velho cara, já era!") else: print("A vida está só começando rapaz!") Error encountered: Qual a sua idade? 45 Traceback (mos...
asked by 28.12.2018 / 01:49
1
answer

Find the largest string using Python

I have the following code: import collections num = int(input('Digite um número inteiro: ')) #Inputar número inteiro binario = bin(num)[2:] #Cortar o 0b sequence = binario collection = collections.Counter(sequence) print('O número binár...
asked by 12.12.2018 / 13:53