Python: 2.5.1 Painting a Wall
Maybe I am missing something here, but if 350 sq ft requires 1 gallon, then 250 sq ft will require 250/350 gallons. So you are being asked (I suppose) to request the area from the user and calculate the paint required for that area.
wall_area=float(input("How big is your wall in square feet? "))
gallons_paint = wall_area / 350
print(wall_area, 'square feet wall will need:')
print(gallons_paint, 'gallons of paint')
For example,
How big is your wall in square feet? 250
250.0 square feet wall will need:
0.7142857142857143 gallons of paint
Though you really ought to format the number to something sensible, as in
print(f'{gallons_paint:.2f} gallons of paint')
which will report
0.71 gallons of paint
With your other number, 576.6 square feet,
How big is your wall in square feet? 578.6
578.6 square feet wall will need:
1.65 gallons of paint
Psycopg2: to upgrade or not to upgrade
Django 2.2 supports PostgreSQL 9.4 and higher. psycopg2 2.5.4 or higher is required, though the latest release is recommended.
No, there is no need to upgrade unless specific features / bug fixes are required.
Although my personal preference is to keep up with the latest versions, especially in dev (of course, reviewing that all dependencies support it).
Yes, you will need to upgrade psycopg2
if you want to work with Postgresql 12, as support for postgresql 12
was added only since psycopg2 2.8.4.
Such core packages are well developed, maintain backwards compatibility, basic functionality barely changes.
One more note: psycopg2 was split into two packages (more separate after 2.8) - psycopg2
and psycopg2-binary
. To not dig into details, this is suggested options to be set in requirements.txt
(if you are using virtualenv):
- for the start -
psycopg2-binary
- if any ssl issues, or want to build from source - then set
psycopg2
Looks like you are using system-wide python packages installation, provided by os distribution repositories.
While would not suggest rushing into switching, would definitely recommend to look into using virtualenv (with helpers such as pipenv or virtualenwrapper) to have nice local python environment individually for each project with packages installed directly from pypi and not bound to os vendor.
Add method to a class which can only be accessed inside specific class
You could use refinements for this:
Due to Ruby's open classes you can redefine or add functionality to existing classes. This is called a “monkey patch”. Unfortunately the scope of such changes is global. All users of the monkey-patched class see the same changes. This can cause unintended side-effects or breakage of programs.
Refinements are designed to reduce the impact of monkey patching on other users of the monkey-patched class. Refinements provide a way to extend a class locally. Refinements can modify both classes and modules.
Something like this:
module HashPatches
refine Hash do
def new_hash_method
# ...
end
end
end
and then:
class YourClass
using HashPatches
def m
{}.new_hash_method
end
end
That would let you call YourClass.new.m
(which would use new_hash_method
) but it wouldn't pollute Hash
globally so outside YourClass
, some_hash.new_hash_method
would be a NoMethodError
.
Reading:
- Official Refinements docs
- Refinements spec
Trying to link sfml and c++ with portable vscode on windows 10
Okay, so basically I just downloaded the wrong version of SFML. I downloaded SFML Visual C++ 15 (2017) - 32-bit
but the one I should have taken is SFML GCC 7.3.0 MinGW (DW2) - 32-bit
. I also had to precise the name of my .exe file in tasks.json
:
"-o",
"${workspaceFolder}/a.exe",
Related Topics
In Python, How to Check If a Date Is Valid
How to Disable Pylint Unused Import Error Messages in VS Code
Send a File Through Sockets in Python
Could Not Find a Version That Satisfies the Requirement in Python
Removing Punctuations and Spaces in a String Without Using Regex
How to Assign Class Instance to a Variable and Use That in Other Class
Sharing a Complex Object Between Processes
When to Use Cla(), Clf() or Close() for Clearing a Plot in Matplotlib
Python: Using Doctests for Classes
Creating a New Dataframe Column by Comparing Strings of Two Unequal Dataframes
Get Max Value Comparing Multiple Columns and Return Specific Values
Get All the Diagonals in a Matrix/List of Lists in Python
Matrix Flip Horizontal or Vertical
How to Split an Integer into an Array of Digits
Pandas: Calculate Total Percent Difference Between Two Data Frames
Reading Columns of a Txt File on Python
Accuracy Score Valueerror: Can't Handle Mix of Binary and Continuous Target