Questions tagged as 'python'

1
answer

Error importing xml.parsers.expat in Python 2.7 only works with Python3

Good morning, a few months ago started with python I'm using it to do tests in android applications. I have the following problem importing xml.parsers.expat . when I run directly on the terminal it works. More if I run using subprocess...
asked by 28.12.2015 / 14:44
3
answers

How to convert an int number to string in python?

I need to do an exercise in which I ignore an integer variable of 3 digits and python has to show it inverted, but until where I know an integer variable can do that, but a string yes. What can I do?     
asked by 23.03.2017 / 19:15
2
answers

Printing specific lines from a text file

Imagine that I have a text file called test.txt with the following content: 4 Março 2017- Sábado meu aniversario -prova de calculo 6 Março 2017- Segunda aniversario do Salomao - fazer compras 8 Março 2017- Qu...
asked by 12.03.2017 / 02:46
3
answers

How to define a vowel without writing all the letters of the alphabet

Type the vowel function that takes a single character as a parameter and returns True if it is a vowel and False if it is a consonant. Notice that Vowel ("a") should return True Vowel ("b") should return False Vowel ("E") should retu...
asked by 06.04.2017 / 09:33
2
answers

How to read hyphen-separated numbers in a text file?

Let's say I have a text file where its configuration is: 1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20...-999 How do I read the file and save each number of the one that is separated by - ?     
asked by 23.11.2017 / 18:31
2
answers

How to make the system display an error message when it is not a number? [duplicate]

How to get the system to return some message of type "This value should be numeric" in the problem below? (menu one and two have already been defined, this is just a cut) print("MENU PRINCIPAL") while True: esc_menu = int(input("\n1) Ir...
asked by 18.11.2017 / 04:28
2
answers

Remove non-numeric characters from a string in Python

Let's suppose, I have: a = "0LÁM@UN@D0 I would like something that removes all the letters (A-Z) and other characters, I just want the numbers to stay in the example, it would only be 0 and 0 b = "A1B2C3" Something that takes away the...
asked by 12.11.2017 / 19:04
2
answers

I understand a parallel execution using fork. How does the fork work?

import os def filho(): print('Ola do filho', os.getpid()) os._exit(0) def pai(): while True: newpid = os.fork()# fornece ID para um novo processo! if newpid == 0: filho() else: print('...
asked by 07.04.2018 / 18:08
2
answers

How to use sys.arg for data entry

I have the function as follows: def minha_funcao(x, y ) my code . . . end of my code e a a entrada de dados eu utlizo da seginte maneira print my_func([uma lista], [outra lista]) I would like to use sys.arg for the person to ent...
asked by 21.12.2016 / 17:18
3
answers

How do I block access to parameter creation in a class?

import math class Circulo(): def __init__(self): super() self.__raio = None def get_perimetro(self): return 2 * math.pi * self.raio def get_area(self): return math.pi * self.raio ** 2 @property...
asked by 17.07.2017 / 05:40