Questions tagged as 'python'

1
answer

How would the conversion of this algorithm from C to Python

unsigned char CheckSum(unsigned char *uBuff, unsigned char uBuffLen){ unsigned char i, uSum=0; for(i=0; i < uBuffLen; i++){ uSum = uSum + uBuff[i]; } uSum = (~uSum) + 1; return uSum; }     
asked by 07.09.2017 / 14:59
1
answer

Save amount of occurrences of a txt file in another txt file in python

This part of the code counts the number of times the words repeat in the text: with open('/Users/DIGITAL/Desktop/Python/teste.txt') as f: ocorrencias = Counter(f.read().split()) This part is used to sort in ascending order: with open(...
asked by 09.10.2017 / 22:09
2
answers

Error when creating a Django simple table?

class Produtos(models.Model): #id = models.AutoField(primary_key=True) nomeproduto = models.CharField(max_length=50, blank=True, null=True) quantproduto = models.CharField(max_length=30, blank=False, unique=True) status = models...
asked by 22.06.2018 / 15:43
1
answer

Get path where python file is called

I created a python file and left it available to access from every location on the system, but for many applications I need the path where the python file was called by the system, but I did not find any way to get this value on the internet, so...
asked by 15.08.2017 / 19:19
2
answers

How to install Opencv

I would like to know how to install the latest version of Opencv 3.2 on Linux ubuntu 14.04. I was able to install and put to compile in codeblocks using C ++ following a tutorial. But my goal is to actually install the opencv library so that I u...
asked by 15.07.2017 / 22:16
1
answer

Check if a key exists in a dictionary

How can I check if a key exists inside a dictionary in Python?     
asked by 18.07.2017 / 01:15
1
answer

Slice proportional to the size of the dataframe

How can I make a slice in the dataframe according to its line size? For example: if the dataframe has 14 rows, split into 2 rows of 7, if you have 28 rows, divide into 3 rows of 7, and so on. Is there any function of the pandas to do this?...
asked by 05.07.2017 / 20:16
1
answer

Logarithmic Scale Chart with Python

Initially I created a chart of Values X time (time in Unix Time) with the following code: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = [] with op...
asked by 22.09.2017 / 17:14
1
answer

TypeError: can not multiply sequence by non-int of type 'float'

I'm learning to program in python , but I came across an error while trying to build merge sort using object orientation. When calling the sort() method that belongs to the MergeSort class, the following error is displ...
asked by 30.06.2017 / 17:15
1
answer

Get and Set using PROPERTY - Python3

As a property learning object, I created a small currency converter. See: class converteMoeda(): def __init__(self, dollar=0, real=0): self.dollar = dollar self.real = real def toDollar(self): dollar = self.real/self.dolla...
asked by 28.06.2017 / 16:44