How do I format a decimal number in Python for a given amount?
For example, I want to display only two decimal places of the following number:
numero_decimal = 3.141592653589793
How could I turn this number to 3.14 ?
I started programming shortly and I'm doing some Python exercises.
The problem is that the result variable always returns "Approved" even when the concept is "D" or "E".
I have already broken my head and can not see the error.
Make a...
I'm developing a regular expression to try to replace accents and characters with ç by normal characters
Example:
á = a
ç = c
é = e
But my regex is only eliminating, any tips?
import re
string_velha = ("Olá você está ???? ")
st...
I'm trying to make a program in Python 3 that should turn typed text into uppercase and remove white space. I would like to know what is wrong with my code since it is not deleting the blanks. I tested two codes.
First code:
print ("-"*50...
Given this list:
nomes = [ " Paulo Ricardo " , " Fabio Junior " , " Roberto Carlos " ]
How do I create a new list by separating the first and last name and only adding the first name without the last name in this new list, using list compre...
Good Night, I'm a beginner in IT and I'm doing a basic python course, I have to implement the following:
Write a program that receives a sequence of integers ending with 0 and prints all values in reverse order. ** Note that 0 (ZERO) should n...
Could someone explain to me the logic of the 'in' operator of python? I've done some testing on idle and I still can not figure out how it works.
>>> (2 or 10) in range(1,6)
True
>>> (10 or 2) in range(1,6)
False
In the ab...
In php, when I want to generate a array formatted, I use the array_map function.
So:
$numeros = range(1, 10);
array_map(function ($value) {
return sprintf('%04', $value);
}, $numeros);
Return:
array('0001', '0002', '...
Suppose I have the following list:
frutas = ['abacate', 'mamão', 'laranja', 'uva', 'pêra']
I need to capture one of these elements of list randomly.
How would I do this in Python?