Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
1
votes1
answer197
viewsUpload file/parameters via HTTP in Java
I was using Python to update some equipment via Post, where I defined some parameters and sent a file, where the equipment itself updates after receiving this file. However, as I developed a Java…
-
1
votes0
answers35
viewsSlugfy in FLASK query
I am trying to give a Slug in a given, I tried to use Lower and replace to swap some characters, my query is similar to this: return…
-
1
votes1
answer255
viewsProblem using vowel lists and even numbers
The exercise is as follows: Make a program where the user type a letter and a number integer. If the letter is vowel and the number is even, or the letter is consonant and odd number, show…
-
1
votes2
answers5037
viewsDecimal to hexadecimal conversion
I need to do a python algorithm to make a decimal to hexadecimal converter. But I can’t use ifs or ready-made functions, like Hex(). I did, but when I went to print the value in hexa I used…
-
1
votes3
answers11136
viewsStore data inside a Python loop array
Good afternoon, you guys. I’ve been learning a lot of C and C++, and the python part too. It confuses me a lot the syntaxes sometimes, because I often think of C and I get confused in python. In the…
-
1
votes1
answer1022
viewsSend or Update button in Tkinter (Python) and Widgets Resizing
Start a code where you have 4 Checksbuttons and I want to do the following: (pseudo-code) user enters the database name, and selects what he wants => name, email, Cpf, color after that the…
-
1
votes1
answer2106
viewsHow to make Python program run in 32 and 64 bits
I have a program made in Python(3.5) under 64 bit operating system, there is the possibility of I make it run in 64 and also in 32 bits in windows? NOTE: I used Pyinstaller to compile the program to…
-
1
votes2
answers444
viewsHow to configure the Django environment and maintain settings?
Hello, I’m starting to learn Django and well part of the material teaches how to Make Environment Setup with Virtualenv. However I am having many difficulties to configure the System. First, I use a…
-
1
votes3
answers2731
viewsProblems with Pip install to install Virtualenvwrapper on Windows
I’m trying to install the virtualenvwrapper to then install Django. For that, I installed the pip, but every time I try to run on CMD: pip install virtualenvwrapper-win Error appears: Could not find…
-
1
votes1
answer1473
viewsManipulation of columns with pandas
I’m running a regression where I have 3 parameters and a column with categories. As sklearn does not recognize categories I turn them into Dummies ( create a column for each category and fill with 1…
-
1
votes1
answer456
viewsProblem with my Hangman game - Python
print("*** Jogo da forca ***\n") print("*** Feito por Igor! ***\n") palavraSecreta = input("Entre com a palavra secreta: ") letrasDescobertas = [] percorrer = 0 contador = int(input("Entre com o…
-
1
votes1
answer186
viewsSlice proportional to dataframe size
How can I perform a Slice on the dataframe according to its line size? For example: if the dataframe has 14 lines, divide into 2 parts of 7, if it has 28 lines, divide into 3 parts of 7, and so on.…
-
1
votes1
answer608
viewsChange encoding in pd.to_datetime
wondered if there is the possibility to change the encoding of an element returned by the function to_datetime pandas. I need to switch to ISO-8859-1 encoding to compare the date with others that…
-
1
votes1
answer40
viewsPython - Conditional Expression
Hello, I am learning Python and in my studies I came across the following situation: >>> responses = ['Y', 'Yes', 'No', 'no', '', 'Yep'] >>> responses = [x[0].lower() if x else 'n'…
-
1
votes2
answers572
viewsManipulating strings in Python
I have a list with n strings. Example: lista = ['0004434-48.2010', 'UNIÃO, '(30 dias úteis) 03/07/2017', '13/07/2017', '0008767-77.2013', 'UNIÃO, '(10 dias úteis) 03/07/2017', '13/07/2017'] My…
pythonasked 7 years, 4 months ago Bergo de Almeida 181 -
1
votes1
answer1465
viewsPython/Pandas - How to compare if column content of the data frame, in date format, is equal to another date column about 1 day?
I have a date frame with two columns in date format and I need to compare if one of them is between the interval of one day more or less than another column. For example: Column A = 2015-03-02…
-
1
votes1
answer160
viewsPython / R Check density peaks in ggplot2
I have two sets of data formed as follows: A= {id1: 0.3, id2: 0.1, id3: 0.3 ... idn: 0.2} B= {id1: 0.01, id2: 0.04, id3: 0.75 ... idn: 0.9} I used the function ggplot R to plot the densities values…
-
1
votes1
answer50
viewsGraph using local time instead of GMT time
import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = [] dataset = open("datasetDdos10Abril2017_unixtime.csv","r") ##separacao no csv…
-
1
votes1
answer1016
viewsDjango runserver does not work
The command: python Manage.py runserver 80 Returns the following: (I put screenshot, because the text is defaced here) The localhost address is inaccessible regardless of the port (8080, 8000, 80)…
-
1
votes1
answer725
viewsHow this recursive function (factorial function) behaves in Python
I don’t understand how the code behaves after it leaves the recursive function on line 7, fat = n * fatorial(n-1), i.e., how the code assigns the value to the variable n of this line and how is done…
-
1
votes1
answer83
viewsAssertionerror: b' Working with test classes in Django (TDD)
I’m starting my test studies with Django and I’m getting an error where apparently it shouldn’t, so much so that the description of traceback leaves me quite confused. I have a class that tests…
-
1
votes2
answers594
viewsHow do I test user type and send to different views in DJANGO Generic views
Hello, I have a question at Django. I’m trying to do it this way. My user model has a "level" field, this field has some levels, among them "root", "seller" etc.. However, I would like to know how I…
-
1
votes2
answers12076
viewsHow to use Python comma instead of a dot
The Brazilian system, unlike the American system, uses the comma to separate decimals, but like Python was made in a country that uses the point to separate decimals, the programs, when we use the…
pythonasked 7 years, 4 months ago Dyefferson Azevedo 129 -
1
votes2
answers3159
viewsPython Taylor series with no angle and error margin
Hello! I need to assemble a program that calculates sine, cosine and exponential Taylor series in Python, but the program cannot accept an angle value, only x, number of series terms and an…
-
1
votes1
answer1831
viewsPython API for real-time commodity values
I need an API that can provide me with real-time commodity prices (more specifically, Arabica Coffee price) I know practically nothing about the stock market, but I did some research and found that…
-
1
votes3
answers2710
viewsget the 3 largest numbers from a python list
someone can help me find the mistake? """Returns a list of the three largest Elements input_list in order from largest to smallest. If input_list has Fewer than three Elements, Return input_list…
-
1
votes1
answer1412
viewsPlay video stored in python web
Imagine that I have video in a directory of a site and not in a tag , example: www.site.com/video.mp4, I can play this video using python + Tkinter ?
-
1
votes1
answer4275
viewsRead CSV file ,Columns
I would like to know how to read a CSV file taking the first and second column and compare the string contained in it with another string I want in the code. Ex.: if(o conteudo do csv coluna…
-
1
votes0
answers387
viewsError: $http:baddata Bad JSON Data
I am finishing developing a web application but I have a problem. All my application was developed in Python, Restful, Angularjs and Chartjs. I am importing information from the database via python…
-
1
votes1
answer500
viewsHow to redirect url with argument to another page in Django? (Updateview, Genericview)
Well, I have a very pertinent question. I am with an editing class of Django, and when I edit the user, I need it to call from the detail class of the same (Detailview), the two classes are working,…
-
1
votes3
answers2758
viewsHow to print without line break in Python
matriz = [] def create_matriz(a, b): for contador in range(a): matriz.append( [0] * b ) def print_matriz(txt): cont = 0 for j in range(a): for i in range(b): if txt[cont] == "0": matriz[i][j] = 0…
-
1
votes1
answer250
viewsDictionary exercise
I can’t seem to solve this exercise. I need the letter indicating the type of service (E,R or F) to be indicated in the same line as the other information, however, according to the letter inserted,…
-
1
votes1
answer782
viewsData overlapping on the x-axis of the graph
I need to place a series of dates (timestamp) that are stored in a bd on the x-axis of a graph, the problem is that the dates overlap and it is impossible to perform an efficient analysis. It…
-
1
votes3
answers366
viewsPython does not return files inside a directory
Good night I am new in Python programming but I created this code using the.listdr and did not return any results of the files inside folder. If anyone has any idea how to handle it, I’d appreciate…
-
1
votes2
answers164
viewsHow to coverter string for timestamp object?
How can I transform a string containing a date, example: 'Thu Jul 27 13:54:22 2017', in a datetime object, or time?
-
1
votes1
answer608
viewsButton does not call function correctly
from tkinter import * class Application: def __init__(self, master=None): self.inicio = Frame(master) self.inicio.pack() self.msg = Label(self.inicio, text="Deseja exprimentar a versao input?")…
-
1
votes1
answer444
viewsUpdate values from a chart using Django
I’m playing in a solo project to make a website to show the current coffee quotation along with a line chart of the daily variation of this price as a function of time. I get the price value of…
-
1
votes2
answers1536
viewsfunction to return the integer number
what I’m doing wrong in my job? num2 = float(input("digite um número não inteiro: ")) def arrend(numero): if num2 - math.floor(num2) < 0.5: numero = math.floor(num2) return numero return…
-
1
votes2
answers660
viewsOS library Python - Locating Directories
I’m learning how to find directories in Python and came across the following code: import os dir_path = os.path.dirname(os.path.realpath(__file__)) print(dir_path) cwd = os.getcwd() print(cwd) Why…
-
1
votes1
answer236
viewsPython Error in if
I am having an error in the if and do not know how to correct this error, I am using Python 3.6 and Pandas for reading, writing and data analysis. df1 = pd.read_csv("JonnyTheBoy10.csv",…
-
1
votes1
answer218
viewsIs this a scam?
I’m starting in programming, I have some difficulty reading codes even my own after a while. I was a researcher on legibility and came across the term "gambiarra". this raised a question for me.…
-
1
votes1
answer407
viewsUpdate console line
I have a python loop, and would like to inform the value of a variable each time it is updated, however I don’t want to dirty the console printing every time and or clean the whole console. There is…
-
1
votes1
answer242
viewsHow to group numeric sequences?
Friends, I have a csv file with 5k lines in which there are purchase transactions. There is an id for each purchase, it occurs that for a lot where several purchases transactions are made there is…
-
1
votes1
answer962
viewsWeb Scraping - convert HTML table to python Dict
I’m trying to turn an HTML table into dict@python, I came across some problems and I ask for your help. Go as far as I can go... def impl12(url='http://www.geonames.org/countries/', tmout=2): import…
-
1
votes2
answers1475
viewsFind the largest palindrome made from the product of two 3-digit numbers - Python
I’m having a problem. I’m creating a Python algorithm to find the largest palindrome made from the product of two 3-digit numbers. Code: i = 0 while i <= 999: temp = str(i * 999) tempInverso =…
-
1
votes1
answer9332
viewsLine break in a file . txt
How to break the line by passing my data to a file. txt? The code I’m using to open, write and close . txt are these: arquivo = open("arquivo.txt", "a", newline="") arquivo.write("%s;" %…
-
1
votes1
answer6789
viewsFind the input of a certain value in a Python list
Guys, I’m doing a function to count the words of a text without repeating them and with that, I also need to count how many times it appears inside that list of strings I used the code below but it…
pythonasked 7 years, 5 months ago Jhonatan Teodoro 33 -
1
votes3
answers3098
viewsUse return of a function in another function
I have a function in Python that takes a text and returns 2 lists, one with all the words that appear and the other returns is the number of times each word appears. def frequencia(lista): conv =…
-
1
votes1
answer311
viewsProblem using function . Join()
What’s wrong with this code of mine, I used the function. split() to separate the string when it finds ' ; ' after separating I wanted to join back by placing spaces so I used the . Join(), but saw…
-
1
votes2
answers134
viewsHow to know which variables are defined?
Is there a function that returns the name of the variables defined in a Python instance? Something similar to the command who in Matlab that returns the names of the user-defined variables.…