Questions tagged as 'python-3.x'

2
answers

input () and raw_input ()

According to the Python 2.x documentation, it is recommended to use the raw_input function instead of input . Conversely, in the Python 3.x documentation, the raw_input function does not even appear. So does the input...
asked by 08.08.2016 / 01:07
2
answers

Problem with the randint function

Hello, I'm having a little problem in my code. I try to generate a list of 4 random integers that do not repeat, but ... list_num = [] c = 0 v = random.randint(0, 9) while c < 4 and v not in list_num: list_num.append(v) c += 1...
asked by 23.03.2015 / 17:17
2
answers

Regular expression to create a line of a rooster game (old game)

I'm trying to use a pattern to find a certain line in a file, but it's not working. This is my pattern: row = re.compile(r"(|\s[OX\s]\s{3}|)") With this I want to basically find this pattern: | | O | X | , that is, I want th...
asked by 24.11.2014 / 16:33
1
answer

How to improve common maximum divisor algorithm - URI 1028

I'm solving this URI problem that basically asks for the maximum common divisor between two values. I originally resolved with math.gcd on half a dozen lines, but the code was not accepted since the URI uses a version of Python 3 pri...
asked by 05.08.2018 / 15:46
2
answers

How to check the versions of modules installed in Python?

I installed two modules in Python via anaconda (conda install): zipfile36 ; MySQLdb . Using the anaconda prompt I get the version of both and all my other modules using the command: conda list But I would like to know, how ca...
asked by 30.10.2018 / 15:29
1
answer

What are file and directory descriptors?

I am studying módulo os of the Python default library and I realize that in many cases a function is allowed to receive as a parameter descritor de arquivo ou diretório some examples are:    os.fchdir(fd)   Change...
asked by 26.10.2018 / 05:04
2
answers

Importing modules with Python

How can I make import libraries, for example, I was searching and found Babel to do internationalization of dates, but I do not know how to import this library?     
asked by 07.08.2015 / 02:43
2
answers

Replace words between two files

I'm trying to make some substitutions between two files: if a word from file 1 is in the second column of file 2, replace that word from file 1 with the word from the first column of file 2 File 1:    bought large carpet expected large p...
asked by 29.06.2018 / 13:50
2
answers

Counting 'nan' and 'null' values in a pandas dataframe

Imagine that we have a CSV file called data.csv: col1 col2 col3 col4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 33 44 import numpy as np import pandas as pd po =...
asked by 24.06.2018 / 21:52
1
answer

Join three similar codes in one

I'm working with a table that shows the number of places offered, candidates who are enrolled and those who enter higher courses. I want to make a program that allows the visualization of this data from the user's input (let's say he wants to kn...
asked by 09.01.2018 / 04:35