Questions tagged as 'python-3.x'

1
answer

Summarize all columns of an array using numpy. Any better way to do it?

I did so: import numpy as np #soma de todas as colunas de mat! mat = np.arange(1,26).reshape(5,5) print(mat) lista =[] for i in np.arange(0,len(mat)): lista.append(np.sum(mat[0:,i:i+1])) print(np.array(lista)) The output is correct:...
asked by 05.05.2018 / 22:42
1
answer

Error: "illegal target for variable annotation" using "@property"

Because pygame does not have a library-like function SFML - > View , I'm developing a "camera" format to scroll the screen and preserve the positions of the objects within the general coordinate within the "world". As default for...
asked by 02.10.2018 / 23:53
1
answer

Why is the class attribute unchanged?

I just need to send a command from one process to another, but I wanted to understand why when modifying the variable within a function, it does not appear in another function. from multiprocessing import Process import time ComandoSerial =...
asked by 18.12.2017 / 12:47
1
answer

What does the class name in super () .__ init __ () mean?

What is the function of the name of the classes inserted inside the parentheses of the constructor __init__( ) , in classes Telefones , TiposTelefone and Agenda ?    This is just a code snippet from Chapter 10 of "Int...
asked by 26.07.2018 / 21:59
1
answer

Convert Days and Time (Hours x Minutes x Seconds) to Time Only

I have a Dataframe where I'm making the difference between two different dates to get the difference in Hours and Minutes, for example: data_inicial = '2018-07-03 16:03:00' data_final = '2018-07-05 00:00:00' duracao = data_final - da...
asked by 05.07.2018 / 18:53
2
answers

Intensive python course by Eric Matthes ex8.10 [closed]

I'm having a hard time doing an exercise in the book 'Intensive python course by Eric Matthes' the exercises is as follows: 8.10 - Great Magicians: Eat with a copy of your exercise program 8.9. Write a function called make_great () that modif...
asked by 06.07.2018 / 19:19
1
answer

Generating functions: What are the advantages of using them?

Generating function: def geraQuadrados(n): for i in range(n): yield i**2 for i in geraQuadrados(5): print(i) No generating function: def novosQuadrados(n): l = [] for i in range(n): l.app...
asked by 05.04.2018 / 14:17
1
answer

Using the def function

I would like to create a function def for the first input and then return it on the third line. Example: def se(): sex = input('Digite seu sexo:') while sex != 'M' and sex != 'F': #não sei como se retorna esta parte:...
asked by 21.11.2017 / 18:48
2
answers

default values for namedtuple

In creating a class I can set some default values: class Point: def __init__(self, x, y, z=0): self.x = x self.y = y self.z = z How to proceed in the same way for namedtuple? from collection import namedtuple P...
asked by 18.08.2017 / 03:49
2
answers

Is it possible to add more than one item to a list at one time?

I wonder if it's possible to add more than one element to a list, for example: a=[] a.append('abóbora', 'banana', 'maçã') or you will need to use three lines, for example: a=[] a.append('abóbora') a.append('banana') a.append('maçã') Pl...
asked by 05.11.2017 / 02:42