Questions tagged as 'python-3.x'

2
answers

Error instantiating objects in python OO

Well, I'm going to gather two doubts about python OO here in this message. I use anaconda (python 3.6.1). I'm trying to make a little project to study object orientation in python 3.6.1. Initially, the problem is in passing the parameters to...
asked by 09.03.2018 / 18:03
2
answers

Nested lists in python

I need a help, let's say I have the following list: lista = [1,2,3,4,5,[6,7,8,9],10,11,12,13,14,15] If I want to print each of the items in this list I would do one: for i in lista: print(lista) So far so good. However, I wanted to...
asked by 07.03.2018 / 14:33
1
answer

What is the purpose of if __name__ == '__main__': if kivy can run the application without this line of code? [duplicate]

In the kivy documentation it shows that pro app works is needed if __name__ == '__main__': MyApp().run() But I try to remove the if condition; and the app performed anyway; Somebody explain to me why, please!     
asked by 02.03.2018 / 15:30
1
answer

What would be the equivalent of find for lists in python?

What would be equivalent to find used in strings to use in lists? For example, if it is a=['a','b','c'] , how do I return to position 1 of 'b' ?     
asked by 12.07.2018 / 13:23
2
answers

Checking a DoS / DDoS (Denial of Service) attack on a network dump (PCAP file)

from scapy.all import * import dpkt f1 = open("semAtaque.pcap") pcap = dpkt.pcap.Reader(f1) f1.close() f2 = open("Ataques.pcap") pcap = dpkt.pcap.Reader(f2) f2.close() I have two network traffic captures for a lab experiment: one free of att...
asked by 10.03.2017 / 18:51
1
answer

Error TypeError: a float is required

This is my code: ### BIBLIOTECAS import scipy.special as sps import numpy as np import matplotlib.pyplot as plt import pandas as pd import scipy as sp from scipy.stats import norm from scipy.stats import gamma from math import exp import oper...
asked by 23.12.2016 / 13:16
4
answers

Place items in lists

I would like to have two lists: one with the name of the fruit and another with the colors. lista = ['banana [amarela]\n', 'uva [vinho]\n', 'laranja [laranjado]\n', 'kiwi [verde]\n', 'framboesa [vermelho]\n', 'coco [marrom]\n'] lines = lista....
asked by 13.09.2017 / 15:32
1
answer

'dict' object has no attribute 'has_key' in Python3

In Python 2, when I wanted to know if a dict had a given key, I used the has_key method. if kwargs.has_key("code"): self.code = kwargs.code However, now that I was running the same script in Python 3, I got the following er...
asked by 04.11.2016 / 14:01
1
answer

Sorting lists with multiple parameters using lambda expression

Given the Ponto class, the ordenar function sorts the list elements by following the following criteria: first value in x , then y and finally value in z . Beauty, the code works. But I would like to understan...
asked by 01.11.2017 / 00:18
1
answer

Create a key / values association from user-entered data

8) Write an algorithm capable of receiving a variable amount of parameters that are associated with a key. Then print the key name and its value on the screen: def func_varios_parametros_dic(**dicionario): print(dicionario) lista_k = []...
asked by 22.11.2018 / 19:20