Questions tagged as 'python'

3
answers

Python - Find the number of numbers greater than the average

I have difficulty with the following question: Write a python function that receives as a parameter a real tuple. The function should return the average and the amount of values greater than the average. And then I came up with the following...
asked by 12.05.2018 / 20:40
2
answers

Calculation of occurrence of strings in list - Python

Personal I need a help to calculate the number of occurrences of a given string in a column of a list. Example: test_list = [['Name', 'Age', 'Sex', 'Occupation'], ['Peter', '25' em> Ex: Calculate the number of occurrences by profession --...
asked by 06.05.2018 / 03:01
2
answers

Python - Detectives and Assassins

I'm having trouble understanding what this exercise in the link below is requesting: link What I've understood so far is that I should build an algorithm so that when the data is provided that algorithm will find out who the killer is an...
asked by 30.04.2018 / 23:30
1
answer

How to write an alphabetical list of names using the Python OrderedDict?

Nomes = [] Telefones = [] Endereços = [] Emails = [] Agenda = {"Nome": Nomes,"Telefone":Telefones,"Endereço":Endereços, "Email": Emails} entrada = "" print("Bem-vindo a nossa Agenda!!!!!") while entrada != "s": nome = input("Digit...
asked by 07.04.2018 / 00:43
1
answer

Write a program in python that reads an 8-digit integer

Write a program that reads an 8-digit integer. The output of your program should be the result of the sum of all digits of the integer entered. If the number entered does not have 8 digits, the program should write 'NAO SEI' (without accents and...
asked by 05.04.2018 / 23:25
1
answer

Converting Boolean values to numbers

How do I make the response from False be 0 and True to 1 equal to C? That is, I want the answer from: u=(1>2) is 0 and not False ? Thank you     
asked by 11.04.2018 / 19:51
1
answer

Comparison of values in list of tuples in python 3.x

My question is how can I interact with this list in order to make comparisons between values. def trocar(vals, posX, posY): temp = vals[posX] vals[posX] = vals[posY] vals[posY] = temp return None def ordenar(valores): tam...
asked by 08.04.2018 / 06:55
1
answer

Bytearray size on disk

Let's suppose I convert any image to bytearray . with open("img.png", "rb") as imageFile: f = imageFile.read() b = bytearray(f) print b[0] How do I know how much disk space this bytearray will occupy if I decide to save it...
asked by 03.07.2018 / 22:22
1
answer

How to create a dictionary and auto increment values?

I need to create a dictionary from a list of integers, where each key contains the value of the sums that are in the list: t = [[1,2],[2,1],[3,1],[4,1],[1,1],[2,2],[1,2]] dicionario = {} for i in t: dicionario[str(i[0])] = 0 for i in t:...
asked by 22.01.2018 / 15:46
1
answer

How to check the type of the elements of a list in Python?

I have a list of data, and I need to verify that all elements are integers or string , or any other data type. Is it possible to check all the elements or need to be one by one? For example: Lista = [0,1,2,3,4,5,6,"7"] I need a function...
asked by 19.01.2018 / 14:13