Questions tagged as 'python'

1
answer

Little doubt with numerical operations

I was doing a function in python that returns me the results (x 'ex) of the bhaskara formula, just to train the logic a little bit. more, but it made me curious. If I raise a negative number squared, the expected result is positive, right?...
asked by 14.04.2015 / 18:16
1
answer

Open multiple files with "with open"

You can open more than one file in a program with with open("meutexto.txt", "r") as f: I did not find anything about it (or did not look right). I know you can do it differently: var = open("meutexto.txt", "r") var_dois = open("meu_segund...
asked by 04.09.2017 / 11:55
1
answer

How to make a sample space using 4.6 and 8-sided data?

I'm doing a 3-sided sample space probability work (one of 4 sides, one of 6 sides and another of 8 sides) I know that the sample space, without repetition between the data, is 4 * 6 * 8 = 192. I saw in a topic here the following script: from...
asked by 15.06.2017 / 03:06
1
answer

How to remove area of interest from the background of an image?

I'm starting to work with image processing in pattern recognition, and I'm having to pre-render the images I'll use. First, I need to highlight the region of interest in the background of the image, can anyone tell me the best technique for this...
asked by 06.10.2018 / 13:50
1
answer

Showing total connections to a certain IP address

I have a network dump (PCAP file) containing slowloris attacks. The following script will show the number of connections to IP 192.168.1.2 on port 80: /usr/sbin/tcpdump -anr myfile.pcap | sed 's/^.*IP \([^:]*\)192.168.1.2.80:.*//p;d' |...
asked by 15.05.2017 / 03:03
2
answers

How to print a vector of integers by removing the last comma in Python 3?

I want to print on the screen a vector of integers on the same line and separated by commas, and I want to remove the comma after the last number. How could I do this in Python? My code looks like this: for i in range(12): print(nume...
asked by 22.05.2017 / 17:44
1
answer

How to create a reliable .desktop file in Linux?

I have the following .desktop file to open a file in Python , it is working, but every time before running it opens a dialog saying that the application launcher is not trustworthy, as shown below: / p> Desktop File: [Desktop Ent...
asked by 08.02.2018 / 16:46
1
answer

Python - Problem when doing print within a loop

I have the following code Python , representative of the game Pedra,Papel,Tesoura . import random listChoices = ["rock","paper","scissor"] print("Choose rock, paper or scissor to play or write exit to leave the game") userChoice =...
asked by 14.02.2017 / 04:14
3
answers

Calling attributes of an object in another class in python

I'm a beginner in python and I wanted to know how I call attributes of another object in another class, because in Java, for example: package model; import java.util.ArrayList; import java.util.List; public class FuncionarioDAO { Produt...
asked by 17.07.2018 / 22:04
1
answer

How can I turn an INI file into a Dict?

How can I transform data from a .ini file into a dict into Python? Is there any way to do this in Python ? [database] host = localhost password = sabe_nada_de_python port = 3306     
asked by 30.09.2016 / 20:09