Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
-1
votes2
answers188
viewsReplace specific strings in the dataframe with empty values
I have a file. csv I’m treating, and the column ap_residencia_status should only be populated with floats but is filled with strings (even numeric values are strings) and the values that should be…
-
-1
votes2
answers112
viewsHow to create a file within a directory?
import os def main(): checkDir = str(input('Escoha o diretório do arquivo Python: ')) if os.path.exists(checkDir): print('O diretório existe!') print() nameDir = str(input('Digite o nome do novo…
-
-1
votes1
answer832
viewsDate query in python calendar?
I’ve been studying python for just over a week, but I’d like to perform a more action or bros as follows. will be placed the monetary value and places the day of closing the card and the day of…
-
-1
votes2
answers409
viewsSave Date and Time File in Python Name
Friends, I’m new in python and I’m trying to save a file that contains the date and time as the file name. That’s my code, but it’s not working. Where am I going wrong? from datetime import date,…
-
-1
votes1
answer94
viewsPython with float variable problems
Galera wrote a program where I decrease a variable in 0.01 and from the third decrease, python simply recognizes the value 0.01 as 0.009999999999988617 and ends up giving problems in my code. In the…
-
-1
votes1
answer948
viewsSort elements of a python dictionary
Hello, I have a csv file, from which I read to a dictionary, the file is as follows: maquina,num,projeto,var,reg,nome,valor br,1,1809123,float,4637,teste1 br,1,1809123,float,4639,teste2…
python-3.xasked 5 years, 6 months ago JonP 5 -
-1
votes1
answer18
viewsHow do I keep the word iris-setosa as text in python: df=pd.read_sql('SELECT class = 'iris-setosa' FROM tbl_iris',cnxn)
Olha o conexão já foi feita com sucesso no SQL Sever, já testei comandos como: df=pd.read_sql('SELECT class FROM tbl_iris',cnxn) ou até mesmo df = pd.read_sql('SELECT…
-
-1
votes1
answer156
viewsHow to find a value between two tags in an HTML text? Other than "XPATH"
I’m trying to extract the value between two HTML tags with Python, I need it between two tags same. I was doing it this way to extract values from a store catalog. But now I have a need to extract…
-
-1
votes1
answer312
viewsStay in Loop until the entered value is negative
Write a program that reads multiple integers until a negative number is typed. The program has to return the smallest and largest number read. I tried to do, but when it comes to show the smallest…
python-3.xasked 4 years, 5 months ago Tryford 41 -
-1
votes2
answers502
viewsAssociating positions with Python elements
Make a program that reads two lists with 10 elements each and calculate another list containing at even positions the values of the first and at odd positions the values of the second. Please help…
-
-1
votes2
answers390
viewsReceive an integer number in the input, calculate and print the sum of the odd digits of this number in the output
I saw a similar doubt and he used this code, but in my case I need him to add up only the odd numbers he gets. For example, when typing 123, instead of adding up 1+2+3 it should add up 1+3 only. How…
-
-1
votes1
answer2202
viewsMake a Program that checks if a typed letter is vowel or consonant
alfa = input("Informe uma letra ou consoante:") if alfa =="a": print("Vogal") elif alfa == "e": print("Vogal") elif alfa == "i": print("Vogal") elif alfa == "o": print("Vogal") elif alfa == "u":…
python-3.xasked 4 years, 2 months ago user7197428 13 -
-1
votes1
answer359
viewsConvert json to Dictionary
I’m trying to convert json the data into a dictionary. This json_test to be a Dict type but actually comes as a list type when I check with type(json1_data). import json json1_file =…
-
-1
votes2
answers50
viewsStrange error in For in Python
Hello, my friend. I’m making a very stupid mistake that I can’t even understand why it’s wrong. a = [1, 4, 5] b = [] for i in range(0,len(a)): c = a[i+1] b.append(c) The mistake is IndexError: list…
-
-1
votes4
answers65
viewsI cannot print a list(vector)
I’m trying to make a decimal to binary converter follow the code: n = int(input('Insira um número decimal para conversão em binário ')) cont = [] aux = 0 while n > 1: if(n % 2 == 0):…
-
-1
votes1
answer66
viewsSplit returning Indexerror
I have a file that the lines have this pattern: 0.22755189537 SN.node[0].Application SENDING BEACON # 0 0.22755189537 SN.node[0].Application Sending [Beacon] of size 105 bytes to communication layer…
-
-1
votes1
answer41
viewsExcept bugging without being called
well, I made a "minigame" with even a save/load system. the problem is that after saving or loading the game, ask to "mine", the script returns me the except command of the first command. guy: i…
-
-1
votes1
answer665
viewsNameerror: name 'mostrar_urls' is not defined
Good afternoon! I’m trying to develop a project/idea I had, only when I went to put the "menubar" in other "parts of the programme" the program does not "whether" run further, can anyone help me…
-
-1
votes1
answer20
viewsMatrix list-to-list conversion doesn’t even work using numpy, how could I be doing this conversion?
import numpy as np X = 10 matriz = [] for i in range(X): matriz.append([]) for l in range(0,X): for c in range(0,1): …
python-3.xasked 4 years ago João Matheus 1 -
-1
votes1
answer52
viewsex de python help!
I caught it in an exercise. in the code you need to have a number n between 0 and 100 and in the next lines a variable representing how much money each one has and be printed the minimum amount for…
-
-1
votes1
answer52
viewscopy text from pygame
Guys, I’ve tried everything and I can’t copy a text from a Pygame window. The code is as follows: import pygame screen = pygame.display.set_mode((800, 600)) pygame.font.init() font1 =…
-
-1
votes2
answers611
viewsHow to overwrite a method
Hello I want to overwrite a method, here is the code of the sheet class: from Aluno import * class Bolsista(Aluno): __bolsa = 0.0 def renovarBolsa(self): print(f"Renovando bolsa de {self._nome}")…
-
-1
votes1
answer43
viewsHow to point the oldest person on a list?
Good afternoon everyone, I have a question about my Python studies. According to the proposed exercise, I should create a list scheme within a larger list where a name and age will be recorded…
python-3.xasked 3 years, 11 months ago Jean Flordemiro 37 -
-1
votes2
answers128
viewsPut a variable inside a spin?
import spintax nome1 = input("Nome: ") nome2 = input("Nome: ") nome3 = input("Nome: ") for z in range(0,10): c = (spintax.spin("{noite|dia|tarde}") print("Boa {}".format(c)) I wanted to put the…
-
-1
votes1
answer84
viewsmodule 'Docker' has no attribute 'Client'
I’m using the Docker-py in version 3.7 of Python and when I try to execute the function that uses it an Attributeerror is returned My code: from django.shortcuts import render from django.http…
-
-1
votes1
answer329
viewsProblem with multiplication of matrices in python
Can anyone tell me what the problem is with this code ? (I’m a beginner). import random def mult(): num_l1, num_c1 = len(mat1), len(mat1[0]) num_l2, num_c2 = len(mat2), len(mat2[0]) for i in…
python-3.xasked 5 years, 4 months ago Bruno Carvalho 17 -
-1
votes2
answers260
viewsAlgorithm that creates a Python queue
Hello, I would like to create an algorithm but I don’t know much how to start it... It would be to write a program to create a queue, represented by a list, and present to the user the options to…
-
-1
votes2
answers434
viewsSecond highest value of a python list
I want to find the second highest value of a list without deleting any elements in it; I tried using the min and max command, but this only works with higher and lower. In case I want you to return…
-
-1
votes1
answer69
viewsFile execution error in pycharm
Good morning, everyone, I’m experiencing a boring situation that I’m having trouble solving. When running the game I’m developing the following image appears: Everything was fine before, the program…
-
-1
votes2
answers212
viewsCreate date variable
I’m starting with Python, I’ve been working with Qlikview for many years and I’m migrating some data processing activities to Python. I would like to create a set with a variable of days and months.…
-
-1
votes1
answer72
viewsedit local variable out of function
Hello! How do I change a local variable from a function by external commands to the function? Example: Create the function def totalValue(type): try: valor = float(texto[0]) except: valor = 0 total…
-
-1
votes1
answer940
views(IJ sequence 4) Why is my Python code giving Runtime error in the URI Online Judge?
I managed to run the program on my computer, however, when I submit to the online test cases it accuses 'Runtime error' and I am not able to circumvent the error. The problem is (Sequence IJ 4), the…
-
-1
votes2
answers194
viewsRaising fraction to power
I need to raise a number to a certain expoente, but I don’t know how to do it in case frações. For example, I know that to raise 2 to terceira potência, I must do 2**3. But if I want to raise 1/2 to…
-
-1
votes2
answers122
viewsTreating a string input when I hit enter without typing anything
Talk to the guys! If anyone can help me? When he asks me if I want to continue and I press enter without typing anything he lets me proceed. I wish that when I hit enter without typing anything it…
-
-1
votes1
answer25
viewsHow to open an app with Speech Recognition?
I would like to create a mini application that opens a file or even another application through Speech recognition, ie I would open it and when I gave the example command: if 'open' in command:…
-
-1
votes3
answers243
viewsHow to save file without overwriting the previous python?
Hello, I am trying to save the name of the video files differently every time the program runs. currently it overwrites the name of the previous video. This is my current code: import cv2…
-
-1
votes2
answers57
viewsHow to use a variable function several times without creating another variable? How to draw a number
import random n = random.randint(1, 6) print('O valor sorteado foi {}'.format(n)) if nd !=n: print('Não foi dessa vez') if nd ==n: print('Parabéns! Você está com sorte') start1 = str(input('Deseja…
python-3.xasked 3 years, 8 months ago Felipe Aguiar 9 -
-1
votes1
answer43
viewsarticles_article.author_id Error
I’ve been following the blog creation tutorial using the previous version of Django 2.0 (this one here: https://youtu.be/zJWhizYFKP0), however I use version 2.0, in the process I have been making…
-
-1
votes4
answers276
viewsPrime numbers with Python
Trying a thousand ways to get this result. Always returns the same thing. number = int(input('Numero: ')) if number >= 1: for i in range(1, number): if number % i != 0: print(number, 'é primo')…
-
-1
votes3
answers123
viewsProblem when denying receipt of a certain value
I need to create a code that receives 2 notes and me average them and I have to necessarily make my program only receive values from 0.0 to 10.0 what is not happening: n1 = float(input('Dígite sua…
-
-1
votes1
answer275
viewsError in exchange for elements in the matrix
I’m trying to exchange two position elements in this matrix. After some changes, the elements begin to exchange among themselves in an apparently random pattern. Could someone identify me the…
-
-1
votes1
answer28
viewsUsing . get() in your window with Tkinter
when I try to use the code: import tkinter as tk window = tk.Tk() texto = tk.Text(window).pack() tk.mainloop() print(texto.get()) to return the value of what I wrote in the variable text the program…
-
-1
votes1
answer67
viewsWhat does an expression between parentheses mean followed by an expression between brackets?
I found this code: nums = [1,2,3,4,5,6,7,8] round(sum(a ** (2, 0.5)[a % 2] for a in nums), 2) My doubt is in this passage (2, 0.5)[a % 2], what name? How it works?…
-
-1
votes1
answer199
viewsHow to get coordinates by mouse click with Python?
I have a code that returns me the value of a color in hexadecimal in a given coordinate, in the case of the code the coordinates are 200 and 200, the problem is that keep putting these values by the…
python-3.xasked 3 years, 6 months ago Maykel 1 -
-1
votes1
answer37
viewsSyntaxerror: invalid syntax data.append)=(R)
It’s giving a syntax error but I believe that’s not it, but I can not identify what’s wrong: ```python #retorno df = carteira.copy() df = df.reset_index() colunas = df.columns columns =…
python-3.xasked 3 years, 4 months ago Marcos 13 -
-1
votes2
answers36
viewsCompare two to two elements of a vector
Good afternoon! I am studying python3 (I am very beginner), and I would like, given a vector, to compare the elements of this vector 2 to 2 to see if they are equal. for example: [2,3,4,4,5] 2…
python-3.xasked 3 years, 4 months ago Rômulo Rebello 9 -
-1
votes1
answer136
viewsHow to unify display windows?
Good afternoon, I’m using 2 cameras in a project, but when I run the code it opens in two different windows, I’m trying to make the two images open in the same window... Can someone help me? Thank…
-
-1
votes1
answer22
viewsHow to make a call from a script that is in another folder
I am developing a process in which it will be necessary to make a call in a script that is in another directory. I have a script that is in the directory /home/ant/tests/mobile/myphone.sh If I…
-
-1
votes2
answers835
viewsPython Spent Fuel Exercise
I’m starting in Python and I’m doing some exercises, I did this spent fuel, but it does not show me the end of the program, ie the result, what is the error? nome = input("Qual é o seu nome?") gasto…
-
-1
votes1
answer321
viewsA more efficient Bruteforce
I have a code I made in a few minutes that was supposed to be a "Bruteforce". works, but after 3 characters, it takes too long. I had some ideas to make it more efficient, such as saving in a…