Questions tagged as 'python-3.x'

1
answer

Pass PHP variable to Python with more than 14 characters

Problem passing Python variable to PHP with more than 14 characters PHP code $p = 123456789101112 $pyscript = 'C:\Users\python\teste.py'; $python = 'C:\Python34\python.exe'; $run = shell_exec("$python $pyscript $p"); Python code im...
asked by 20.10.2017 / 00:42
2
answers

Why is the variable unchanged?

I have the following code below: #!/usr/bin/python3 # VARIÁVEIS variavel = 0 def valores(): if ( variavel == 0): variavel = 100 elif (variavel == 1): variavel = 200 elif (variavel == 2): variavel = 3...
asked by 26.02.2018 / 20:00
2
answers

Why divide this operation into two causes change in result?

I made a simple algorithm that solved Fibonacci in 2 logical operations inside the loop. I decided to look for a better way and found a version that does in only 1 calculation in of the loop. It worked perfectly, but when I went to understand...
asked by 20.02.2018 / 03:01
2
answers

Datetime without the year

I need to represent holidays and in my holiday class I need to set the start date and end of the holiday. As the start and end date I need to enter only the month, day, hour and minute . But the datetime class of python requires that the year...
asked by 25.05.2018 / 16:21
2
answers

Python reserved word yield

What's the difference between the following codes? def bottom(): yield 42 def bottom(): return (yield 42)     
asked by 24.06.2018 / 06:14
1
answer

String search with "|" character

I need to perform a query in a txt file in Python, however I have 2 problems due to the interpretation of special characters. When I enter | or \ the result ends up being replaced: | is interrupted as white space and \...
asked by 04.09.2018 / 15:45
2
answers

Result of multiplication and division with two houses after the comma

Hello everyone, how are you? I'm doing an activity for my python course, it's a script that basically calculates the area of a wall in meters and tells how many gallons will be used for paint. The problem is that when I type a very high value...
asked by 19.06.2018 / 01:06
2
answers

How does Python maintain the same memory reference of a list after resizing it?

We know that objects of type list , because they are based on dynamic vectors, have a maximum internal capacity. We also know that when full capacity is reached and we want to insert a new value into the list, Python allocates a new array...
asked by 10.10.2017 / 17:10
2
answers

Correct incorrect module return [duplicate]

Mathematically speaking why it happens and how to correct the following "error" in python: >>>10.53 % 1 0.5299999999999994 I'd like to understand how python works to get this value, why this occurs. In fact the duplica...
asked by 13.10.2017 / 06:26
1
answer

Use from module import * vs use import module in python 3

The two do the same thing (I think at least), but I've always been told that import module is better so I've always used this method, but the / strong> leaves the code more concise since you do not have to be calling the module all the time....
asked by 29.10.2017 / 16:45