Create an account


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,091
» Latest member: tomen44
» Forum threads: 21,716
» Forum posts: 22,579

Full Statistics

Online Users
There are currently 942 online users.
» 0 Member(s) | 936 Guest(s)
Applebot, Baidu, Bing, DuckDuckGo, Google, Yandex

 
  (Indie Deal) House Flipper VR & Car Trader Simulator Deal, More Sale
Posted by: xSicKxBot - 08-26-2023, 06:15 PM - Forum: Deals or Specials - No Replies

(Indie Deal) House Flipper VR & Car Trader Simulator Deal, More Sale

[www.indiegala.com]
House Flipper VR Deal
[www.indiegala.com]
Virtual makeovers were never more real!
https://www.youtube.com/watch?v=ne09_iDXWK4&ab_channel=FrozenWay
Summer Sale
[www.indiegala.com]
Car Trader Simulator Deal
[www.indiegala.com]
Welcome to the Car Trader Simulator! It's here where you'll be able to play the role of the American car dealer who is going to make his business famous in the whole city.
https://www.youtube.com/watch?v=RU0t2ZE8L64&ab_channel=LiveMotionGames


https://steamcommunity.com/groups/indieg...0464469636

Print this item

  [Tut] Python zip(): Get Elements from Multiple Lists
Posted by: xSicKxBot - 08-26-2023, 01:28 AM - Forum: Python - No Replies

[Tut] Python zip(): Get Elements from Multiple Lists

5/5 – (1 vote)

Understanding zip() Function


The zip() function in Python is a built-in function that provides an efficient way to iterate over multiple lists simultaneously. As this is a built-in function, you don’t need to import any external libraries to use it.

The zip() function takes two or more iterable objects, such as lists or tuples, and combines each element from the input iterables into a tuple. These tuples are then aggregated into an iterator, which can be looped over to access the individual tuples.

Here is a simple example of how the zip() function can be used:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']
zipped = zip(list1, list2) for item1, item2 in zipped: print(item1, item2)

Output:

1 a
2 b
3 c

The function also works with more than two input iterables:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']
list3 = [10, 20, 30] zipped = zip(list1, list2, list3) for item1, item2, item3 in zipped: print(item1, item2, item3)

Output:

1 a 10
2 b 20
3 c 30

Keep in mind that the zip() function operates on the shortest input iterable. If any of the input iterables are shorter than the others, the extra elements will be ignored. This behavior ensures that all created tuples have the same length as the number of input iterables.

list1 = [1, 2, 3]
list2 = ['a', 'b'] zipped = zip(list1, list2) for item1, item2 in zipped: print(item1, item2)

Output:

1 a
2 b

To store the result of the zip() function in a list or other data structure, you can convert the returned iterator using functions like list(), tuple(), or dict().

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']
zipped = zip(list1, list2) zipped_list = list(zipped)
print(zipped_list)

Output:

[(1, 'a'), (2, 'b'), (3, 'c')]

Feel free to improve your Python skills by watching my explainer video on the zip() function:

YouTube Video

Working with Multiple Lists



Working with multiple lists in Python can be simplified by using the zip() function. This built-in function enables you to iterate over several lists simultaneously, while pairing their corresponding elements as tuples.

For instance, imagine you have two lists of the same length:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']

You can combine these lists using zip() like this:

combined = zip(list1, list2)

The combined variable would now contain the following tuples: (1, 'a'), (2, 'b'), and (3, 'c').

To work with multiple lists effectively, it’s essential to understand how to get specific elements from a list. This knowledge allows you to extract the required data from each list element and perform calculations or transformations as needed.

In some cases, you might need to find an element in a list. Python offers built-in list methods, such as index(), to help you search for elements and return their indexes. This method is particularly useful when you need to locate a specific value and process the corresponding elements from other lists.

As you work with multiple lists, you may also need to extract elements from Python lists based on their index, value, or condition. Utilizing various techniques for this purpose, such as list comprehensions or slices, can be extremely beneficial in managing and processing your data effectively.

multipled = [a * b for a, b in zip(list1, list2)]

The above example demonstrates a list comprehension that multiplies corresponding elements from list1 and list2 and stores the results in a new list, multipled.

In summary, the zip() function proves to be a powerful tool for combining and working with multiple lists in Python. It facilitates easy iteration over several lists, offering versatile options to process and manipulate data based on specific requirements.

Creating Tuples


The zip() function in Python allows you to create tuples by combining elements from multiple lists. This built-in function can be quite useful when working with parallel lists that share a common relationship. When using zip(), the resulting iterator contains tuples with elements from the input lists.

To demonstrate once again, consider the following two lists:

names = ["Alice", "Bob", "Charlie"]
ages = [25, 30, 35]

By using zip(), you can create a list of tuples that pair each name with its corresponding age like this:

combined = zip(names, ages)

The combined variable now contains an iterator, and to display the list of tuples, you can use the list() function:

print(list(combined))

The output would be:

[('Alice', 25), ('Bob', 30), ('Charlie', 35)]

Zip More Than Two Lists


The zip() function can also work with more than two lists. For example, if you have three lists and want to create tuples that contain elements from all of them, simply pass all the lists as arguments to zip():

names = ["Alice", "Bob", "Charlie"]
ages = [25, 30, 35]
scores = [89, 76, 95] combined = zip(names, ages, scores)
print(list(combined))

The resulting output would be a list of tuples, each containing elements from the three input lists:

[('Alice', 25, 89), ('Bob', 30, 76), ('Charlie', 35, 95)]

? Note: When dealing with an uneven number of elements in the input lists, zip() will truncate the resulting tuples to match the length of the shortest list. This ensures that no elements are left unmatched.

Use zip() when you need to create tuples from multiple lists, as it is a powerful and efficient tool for handling parallel iteration in Python.

Working with Iterables


A useful function for handling multiple iterables is zip(). This built-in function creates an iterator that aggregates elements from two or more iterables, allowing you to work with several iterables simultaneously.

Using zip(), you can map similar indices of multiple containers, such as lists and tuples. For example, consider the following lists:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']

You can use the zip() function to combine their elements into pairs, like this:

zipped = zip(list1, list2)

The zipped variable will now contain an iterator with the following element pairs: (1, 'a'), (2, 'b'), and (3, 'c').

It is also possible to work with an unknown number of iterables using the unpacking operator (*).

Suppose you have a list of iterables:

iterables = [[1, 2, 3], "abc", [True, False, None]]

You can use zip() along with the unpacking operator to combine their corresponding elements:

zipped = zip(*iterables)

The result will be: (1, 'a', True), (2, 'b', False), and (3, 'c', None).

? Note: If you need to filter a list based on specific conditions, there are other useful tools like the filter() function. Using filter() in combination with iterable handling techniques can optimize your code, making it more efficient and readable.

Using For Loops


The zip() function in Python enables you to iterate through multiple lists simultaneously. In combination with a for loop, it offers a powerful tool for handling elements from multiple lists. To understand how this works, let’s delve into some examples.

Suppose you have two lists, letters and numbers, and you want to loop through both of them. You can employ a for loop with two variables:

letters = ['a', 'b', 'c']
numbers = [1, 2, 3]
for letter, number in zip(letters, numbers): print(letter, number)

This code will output:

a 1
b 2
c 3

Notice how zip() combines the elements of each list into tuples, which are then iterated over by the for loop. The loop variables letter and number capture the respective elements from both lists at once, making it easier to process them.

If you have more than two lists, you can also employ the same approach. Let’s say you want to loop through three lists, letters, numbers, and symbols:

letters = ['a', 'b', 'c']
numbers = [1, 2, 3]
symbols = ['@', '#', '$']
for letter, number, symbol in zip(letters, numbers, symbols): print(letter, number, symbol)

The output will be:

a 1 @
b 2 #
c 3 $

Unzipping Elements


In this section, we will discuss how the zip() function works and see examples of how to use it for unpacking elements from lists. For example, if you have two lists list1 and list2, you can use zip() to combine their elements:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']
zipped = zip(list1, list2)

The result of this operation, zipped, is an iterable containing tuples of elements from list1 and list2. To see the output, you can convert it to a list:

zipped_list = list(zipped) # [(1, 'a'), (2, 'b'), (3, 'c')]

Now, let’s talk about unpacking elements using the zip() function. Unpacking is the process of dividing a collection of elements into individual variables. In Python, you can use the asterisk * operator to unpack elements. If we have a zipped list of tuples, we can use the * operator together with the zip() function to separate the original lists:

unzipped = zip(*zipped_list)
list1_unpacked, list2_unpacked = list(unzipped)

In this example, unzipped will be an iterable containing the original lists, which can be converted back to individual lists using the list() function:

list1_result = list(list1_unpacked) # [1, 2, 3]
list2_result = list(list2_unpacked) # ['a', 'b', 'c']

The above code demonstrates the power and flexibility of the zip() function when it comes to combining and unpacking elements from multiple lists. Remember, you can also use zip() with more than two lists, just ensure that you unpack the same number of lists during the unzipping process.

Working with Dictionaries


Python’s zip() function is a fantastic tool for working with dictionaries, as it allows you to combine elements from multiple lists to create key-value pairs. For instance, if you have two lists that represent keys and values, you can use the zip() function to create a dictionary with matching key-value pairs.

keys = ['a', 'b', 'c']
values = [1, 2, 3]
new_dict = dict(zip(keys, values))

The new_dict object would now be {'a': 1, 'b': 2, 'c': 3}. This method is particularly useful when you need to convert CSV to Dictionary in Python, as it can read data from a CSV file and map column headers to row values.

Sometimes, you may encounter situations where you need to add multiple values to a key in a Python dictionary. In such cases, you can combine the zip() function with a nested list comprehension or use a default dictionary to store the values.

keys = ['a', 'b', 'c']
values1 = [1, 2, 3]
values2 = [4, 5, 6] nested_dict = {key: [value1, value2] for key, value1, value2 in zip(keys, values1, values2)}

Now, the nested_dict object would be {'a': [1, 4], 'b': [2, 5], 'c': [3, 6]}.

Itertools.zip_longest()


When you have uneven lists and still want to zip them together without missing any elements, then itertools.zip_longest() comes into play. It provides a similar functionality to zip(), but fills in the gaps with a specified value for the shorter iterable.

from itertools import zip_longest list1 = [1, 2, 3, 4]
list2 = ['a', 'b', 'c']
zipped = list(zip_longest(list1, list2, fillvalue=None))
print(zipped)

Output:

[(1, 'a'), (2, 'b'), (3, 'c'), (4, None)]

Error Handling and Empty Iterators


When using the zip() function in Python, it’s important to handle errors correctly and account for empty iterators. Python provides extensive support for exceptions and exception handling, including cases like IndexError, ValueError, and TypeError.

An empty iterator might arise when one or more of the input iterables provided to zip() are empty. To check for empty iterators, you can use the all() function and check if iterables have at least one element. For example:

def zip_with_error_handling(*iterables): if not all(len(iterable) > 0 for iterable in iterables): raise ValueError("One or more input iterables are empty") return zip(*iterables)

To handle exceptions when using zip(), you can use a tryexcept block. This approach allows you to catch and print exception messages for debugging purposes while preventing your program from crashing. Here’s an example:

try: zipped_data = zip_with_error_handling(list1, list2)
except ValueError as e: print(e)

In this example, the function zip_with_error_handling() checks if any of the input iterables provided are empty. If they are, a ValueError is raised with a descriptive error message. The tryexcept block then catches this error and prints the message without causing the program to terminate.

By handling errors and accounting for empty iterators, you can ensure that your program runs smoothly when using the zip() function to get elements from multiple lists. Remember to use the proper exception handling techniques and always check for empty input iterables to minimize errors and maximize the efficiency of your Python code.

Using Range() with Zip()


Using the range() function in combination with the zip() function can be a powerful technique for iterating over multiple lists and their indices in Python. This allows you to access the elements of multiple lists simultaneously while also keeping track of their positions in the lists.

One way to use range(len()) with zip() is to create a nested loop. First, create a loop that iterates over the range of the length of one of the lists, and then inside that loop, use zip() to retrieve the corresponding elements from the other lists.

For example, let’s assume you have three lists containing different attributes of products, such as names, prices, and quantities.

names = ["apple", "banana", "orange"]
prices = [1.99, 0.99, 1.49]
quantities = [10, 15, 20]

To iterate over these lists and their indices using range(len()) and zip(), you can write the following code:

for i in range(len(names)): for name, price, quantity in zip(names, prices, quantities): print(f"Index: {i}, Name: {name}, Price: {price}, Quantity: {quantity}")

This code will output the index, name, price, and quantity for each product in the lists. The range(len()) construct generates a range object that corresponds to the indices of the list, allowing you to access the current index in the loop.

Frequently Asked Questions


How to use zip with a for loop in Python?


Using zip with a for loop allows you to iterate through multiple lists simultaneously. Here’s an example:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c'] for num, letter in zip(list1, list2): print(num, letter) # Output:
# 1 a
# 2 b
# 3 c

Can you zip lists of different lengths in Python?


Yes, but zip will truncate the output to the length of the shortest list. Consider this example:

list1 = [1, 2, 3]
list2 = ['a', 'b'] for num, letter in zip(list1, list2): print(num, letter) # Output:
# 1 a
# 2 b

What is the process to zip three lists into a dictionary?


To create a dictionary from three lists using zip, follow these steps:

keys = ['a', 'b', 'c']
values1 = [1, 2, 3]
values2 = [4, 5, 6] zipped = dict(zip(keys, zip(values1, values2)))
print(zipped) # Output:
# {'a': (1, 4), 'b': (2, 5), 'c': (3, 6)}

Is there a way to zip multiple lists in Python?


Yes, you can use the zip function to handle multiple lists. Simply provide multiple lists as arguments:

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']
list3 = [4, 5, 6] for num, letter, value in zip(list1, list2, list3): print(num, letter, value) # Output:
# 1 a 4
# 2 b 5
# 3 c 6

How to handle uneven lists when using zip?


If you want to keep all elements from the longest list, you can use itertools.zip_longest:

from itertools import zip_longest list1 = [1, 2, 3]
list2 = ['a', 'b'] for num, letter in zip_longest(list1, list2, fillvalue=None): print(num, letter) # Output:
# 1 a
# 2 b
# 3 None

Where can I find the zip function in Python’s documentation?


The zip function is part of Python’s built-in functions, and its official documentation can be found on the Python website.

? Recommended: 26 Freelance Developer Tips to Double, Triple, Even Quadruple Your Income

The post Python zip(): Get Elements from Multiple Lists appeared first on Be on the Right Side of Change.



https://www.sickgaming.net/blog/2023/08/...ple-lists/

Print this item

  (Indie Deal) Cyber Whale 4 Bundle, Vorax Confession, Funcom & Jagex Deals
Posted by: xSicKxBot - 08-26-2023, 01:26 AM - Forum: Deals or Specials - No Replies

(Indie Deal) Cyber Whale 4 Bundle, Vorax Confession, Funcom & Jagex Deals



We will be going to Gamescom 2023 in Cologne, Germany next week! Find us at Hall 10.1 | Stand B093 with the newest version of Vorax with all of its new additions on a massive and expanded map.

Cyber Whale 4 Bundle | 6 Steam Games | 97% OFF
[www.indiegala.com]
Add to your collection & get a selection of games made with heart and mind brought to you by Whale Rock Games for passionate gamers.
[www.indiegala.com]
Tales & Tactics is out | 36% OFF
[www.indiegala.com]
Roguelike strategy with a squad-based auto battler, creating a deep and rich one-of-a-kind experience tailor-made for a single-player adventure.
https://www.youtube.com/watch?v=L_PrxQJXHWE&ab_channel=YogscastGames
Summer Sale
[www.indiegala.com]
Remnant II is OUT
[www.indiegala.com]
A sequel to the best-selling game Remnant: From the Ashes that pits survivors of humanity against new deadly creatures and god-like bosses
https://www.youtube.com/watch?v=zU6_2QnhP3U&ab_channel=Remnant2


https://steamcommunity.com/groups/indieg...0461352563

Print this item

  PC - The Expanse: A Telltale Series - Episode 2
Posted by: xSicKxBot - 08-26-2023, 01:26 AM - Forum: New Game Releases - No Replies

PC - The Expanse: A Telltale Series - Episode 2



A routine scavenging mission in the Belt has turned into a deadly standoff with relentless pirates. Camina Drummer, as the new captain, faces her first test: outnumbered and outgunned, the crew of The Artemis must formulate an escape plan and gather the supplies desperately needed to get away.

Publisher: Telltale Games

Release Date: Aug 10, 2023




https://www.metacritic.com/game/pc/the-e...-episode-2

Print this item

  [Tut] Bitcoin Is Not Bad For the Environment
Posted by: xSicKxBot - 08-25-2023, 06:15 AM - Forum: Python - No Replies

[Tut] Bitcoin Is Not Bad For the Environment

5/5 – (2 votes)

? Story: Alice has just been orange-pilled and decides to spend a few hours reading Bitcoin articles.

She lands on a mainstream media article on “Bitcoin’s high energy consumption” proposing alternative (centralized) “green coins” that supposedly solve the problem of high energy consumption.

Alice gets distracted and invests in green tokens, effectively buying the bags of marketers promoting green crypto.

After losing 99% of her money, she’s disappointed by the whole industry and concludes that Bitcoin is not for her because the industry is too complex and full of scammers.

Here’s one of those articles recommending five centralized shitcoins:


Here’s another article with shallow content and no unique thought:


In this article, I’ll address Bitcoin’s energy “concern” quickly and efficiently. Let’s get started! ???

Bitcoin Is Eco #1: Inbuilt Incentive to Use Renewable Energy Sources



Miners, who are responsible for validating transactions and securing the network, are driven by profit. Consequently, Bitcoin’s decentralized nature and proof-of-work consensus mechanism have an inbuilt incentive to use renewable energy sources where they are cheapest.

? Renewable energy often provides a more cost-effective solution, leading miners to gravitate towards these sources naturally:

Source: Wikipedia

This non-competition with other energy consumers ensures that Bitcoin’s energy consumption is sustainable and environmentally friendly.

? Renewable energy (specifically: solar energy) offers the lowest-cost energy sources. Fossil-powered miners operate at lower profitability and tend to lose market share compared to renewable-powered miners.

Consider these statistics:

☀ The Bitcoin Mining Council (BMC), a global forum of mining companies that represents 48.4% of the worldwide bitcoin mining network, estimated that in Q4 2022, renewable energy sources accounted for 58.9% of the electricity used to mine bitcoin, a significant improvement compared to 36.8% estimated in Q1 2021 (source).

In the first half of 2023, the members are utilizing electricity with a sustainable power mix of 63.1%, thereby contributing to a slight improvement in the global Bitcoin mining industry’s sustainable electricity mix to 59.9% (source).

Bitcoin is one of the greenest industries on the planet; year after year, it becomes greener!

Bitcoin Is Eco #2: Monetizing Stranded Energy



  • Bitcoin’s energy consumption provides a way to use excess energy that would otherwise go to waste.
  • For example, solar panels often generate more energy than needed, especially during peak hours.
  • Batteries are still expensive and not easily accessible everywhere. Also, they don’t solve the fundamental problem of excess energy — they only buffer it.
  • Bitcoin mining can consume this excess energy, ensuring that it is not wasted and contributing to the overall efficiency of the energy system.

Bitcoin’s role as an energy consumer of last resort is an innovative solution to a modern problem. By tapping into excess energy from renewable sources like solar, wind, and hydroelectric power, Bitcoin mining ensures that energy that would otherwise go to waste is put to productive use.

This is called stranded energy, and energy insiders already propose to use Bitcoin as a solution to utilize stranded energy in economically and ecologically viable ways:

? Bitcoin’s energy consumption is not merely a drain on resources but a strategic tool for enhancing the energy system’s efficiency and sustainability.

By acting as a consumer of last resort, Bitcoin mining transforms a potential waste into a valuable asset, fostering economic development, encouraging renewable energy, and offering a flexible solution to energy grid stabilization.

Bitcoin Is Eco #3: Incentivizing Renewable Energy Development


TL;DR: According to Wright’s Law, technological innovation leads to a reduction in costs over time. Bitcoin’s demand for energy incentivizes developing and deploying renewable energy sources, such as solar and wind power, which, in turn, helps to reduce the cost per kilowatt-hour, making renewable energy more accessible and appealing to other industries as well.


Being able to monetize stranded energy (see previous point #2) not only contributes to the overall efficiency of the energy system but also encourages further investments in renewable energy sources, driving innovation in energy-efficient technologies.

And with more investments in solar energy, the price per kWh continues to drop due to Wrights Law accelerating the renewable energy transition.

? In a Nutshell: More Bitcoin Mining --> More Solar Energy --> Lower Cost per kwh --> More Solar Energy

What sets Bitcoin mining apart is its geographical flexibility and ability to turn on and off like a battery for the energy grid. Mining operations can be strategically located near renewable energy sources, consuming excess energy when available and pausing when needed elsewhere.

This unique characteristic allows Bitcoin mining to act as a stabilizing force in the energy grid, reducing the need for energy storage or wasteful dissipation of excess stranded energy and providing economic incentives for both energy producers and local communities.

Bitcoin Is Eco #4: No It Won’t Consume All the World’s Energy



Contrary to popular belief, Bitcoin’s energy consumption does not grow linearly with Bitcoin adoption and price. Instead, it grows logarithmically with the Bitcoin price, meaning it will likely never exceed 1-2% of the Earth’s total energy consumption.


And even if it were to exceed a few percentage points, it’ll use mostly stranded energy (see previous points #2 and #3) and won’t be able to compete with other energy consumers such as:

  1. Data Centers: High energy for cooling and uninterrupted operation.
  2. Hospitals: Continuous power for life-saving equipment and systems.
  3. Manufacturing Facilities: Energy for uninterrupted production processes.

These will always be able to pay a higher price for energy than Bitcoin.

Bitcoin’s energy consumption isn’t a big deal, even without considering its ecological benefits (see point #5).

Bitcoin Is Eco #5: Bitcoin’s Utility Overcompensates For Its Energy Use



Like everything else, Bitcoin has not only costs but also benefits. The main argument of Bitcoiners is, of course, the high utility the new system provides.

Bitcoin’s decentralized financial system reduces the need for the traditional financial sector’s overhead, such as large buildings, millions of employees, and other expenses related to gold extraction and banking operations. Bitcoin is the superior and more efficient technology that will more than half the energy costs of the financial system.

Source: Nasdaq

For example, this finding shows that both the traditional banking sector and gold need more energy than Bitcoin.

“A 2021 study by Galaxy Digital provided similar findings. It stated that Bitcoin consumed 113.89 terawatt hours (TWh) per year, while the banking sector consumed 263.72 TWh per year.

[…] According to the CBECI, the annual power consumption of gold mining stands at 131 TWh of electricity per year. That’s 10 percent more than Bitcoin’s 120 TWh. This further builds the case for Bitcoin as an emerging digital gold.” (CNBC)

And this doesn’t include the energy benefits that could accrue to Bitcoin when replacing much of the monetary premium in real estate:

? Recommended: 30 Reasons Bitcoin Is Superior to Real Estate

Bitcoin Is Eco #6: Deflationary Benefits to the Economy


TL;DR: Bitcoin’s deflationary nature encourages saving rather than spending. A Bitcoin standard will lead to a reduction in overall consumption, which has significant ecological benefits.


Bitcoin, a deflationary currency with a capped supply, may offer environmental benefits by reducing consumption. Traditional economies, driven by inflation, encourage spending, often resulting in overconsumption and waste.

For instance, wars are usually funded more by inflation rather than taxation. Millions of people buy cars and houses they can’t afford with debt, the source of all inflation.

In contrast, Bitcoin’s deflationary nature incentivizes saving, leading to decreased and highly rational consumption. Because BTC money cannot be printed, the economy would have much lower debt levels, so excess consumption is far less common in deflationary environments.

Reduced consumption can benefit the environment in several ways. Lower demand for goods means fewer greenhouse gas emissions from manufacturing and transportation. It also means less pollution from resource extraction and waste.

All technological progress is deflationary, i.e., goods become cheaper and not more expensive with technological progress. A deflationary economy promotes sustainable businesses that deliver true value without excess overhead making the economic machine much more efficient and benefitting all of us.

Mainstream Keynesian economists do not share the view that deflation is good for the economy, so I added this summary of an essay from the Mises Institute: ?

“Deflation Is Always Good for the Economy” (Mises Institute)


Main Thesis: Deflation, defined as a general decline in prices of goods and services, is always good for the economy, contrary to the popular belief that it leads to economic slumps. The real problem is not deflation itself, but policies aimed at countering it.

Supporting Arguments:

  1. Misunderstanding of Deflation: Most experts believe that deflation generates expectations for further price declines, causing consumers to postpone purchases, which weakens the economy. However, this view is based on a misunderstanding of deflation and inflation.
  2. Inflation is Not Essentially a Rise in Prices: Inflation is not about general price increases, but about the increase in the money supply. Price increases are often a result of an increase in the money supply, but not always. Prices can fall even with an increase in the money supply if the supply of goods increases at a faster rate.
  3. Rising Prices Aren’t the Problem with Inflation: Inflation is harmful not because of price increases, but because of the damage it inflicts on the wealth-formation process. Money created out of thin air (e.g., by counterfeiting or loose monetary policies) diverts real wealth toward the holders of new money, leaving less real wealth to fund wealth-generating activities. This weakens economic growth.
  4. Easy-Money Policies Divert Resources to Non-Productive Activities: Increases in the money supply give rise to non-productive activities, or “bubble activities,” which cannot stand on their own and require the diversion of wealth from wealth generators. Loose monetary policies aimed at fighting deflation support these non-productive activities, weakening the foundation of the economy.
  5. Allowing Non-Productive Activities to Fail: Once non-productive activities are allowed to fail and the sources of the increase in the money supply are sealed off, a genuine, real-wealth expansion can ensue. With the expansion of real wealth for a constant stock of money, prices will fall, which is always good news.

Facts and Stats:

  1. Inflation Target: Mainstream thinkers view an inflation rate of 2% as not harmful to economic growth, and the Federal Reserve’s inflation target is 2%.
  2. Example of Inflation: If the money supply increases by 5% and the quantity of goods increases by 10%, prices will fall by 5%, ceteris paribus, despite the fact that there is an inflation of 5% due to the increase in the money supply.
  3. Example of Company Departments: In a company with 10 departments, if 8 departments are making profits and 2 are making losses, a responsible CEO will shut down or restructure the loss-making departments. Failing to do so diverts funding from wealth generators to loss-making departments, weakening the foundation of the entire company.

?‍? To summarize, Bitcoin has the potential to gradually shift our inflationary, high-consumption economy to a deflationary rational consumption economy while providing a more efficient and greener digital financial system that doesn’t rely on centralized parties and has built-in trust and robustness unmatched by any other financial institution.

The myth of Bitcoin’s high energy consumption is rooted in misunderstandings and oversimplifications. When examined closely, the cryptocurrency’s energy usage reveals a complex interplay of incentives, efficiencies, and innovations that not only mitigate its environmental impact but also contribute positively to global energy dynamics.

Bitcoin’s alignment with renewable energy, utilization of excess energy, incentivization of renewable energy development, logarithmic growth of energy consumption, and deflationary nature all point to a more sustainable and ecologically beneficial system.

As the world continues to grapple with environmental challenges, it is essential to approach the subject of Bitcoin’s energy consumption with an open mind and a willingness to engage with the facts. The evidence suggests that Bitcoin is not the environmental villain it is often portrayed to be, but rather a part of the solution to a more sustainable future.

? Recommended: Are Energy Costs and CapEx Invested in Bitcoin Worth It?

The post Bitcoin Is Not Bad For the Environment appeared first on Be on the Right Side of Change.



https://www.sickgaming.net/blog/2023/08/...vironment/

Print this item

  (Indie Deal) Cyber Whale 4 Bundle, Vorax Confession, Funcom & Jagex Deals
Posted by: xSicKxBot - 08-25-2023, 06:15 AM - Forum: Deals or Specials - No Replies

(Indie Deal) Cyber Whale 4 Bundle, Vorax Confession, Funcom & Jagex Deals



We will be going to Gamescom 2023 in Cologne, Germany next week! Find us at Hall 10.1 | Stand B093 with the newest version of Vorax with all of its new additions on a massive and expanded map.

Cyber Whale 4 Bundle | 6 Steam Games | 97% OFF
[www.indiegala.com]
Add to your collection & get a selection of games made with heart and mind brought to you by Whale Rock Games for passionate gamers.
[www.indiegala.com]
Tales & Tactics is out | 36% OFF
[www.indiegala.com]
Roguelike strategy with a squad-based auto battler, creating a deep and rich one-of-a-kind experience tailor-made for a single-player adventure.
https://www.youtube.com/watch?v=L_PrxQJXHWE&ab_channel=YogscastGames
Summer Sale
[www.indiegala.com]
Remnant II is OUT
[www.indiegala.com]
A sequel to the best-selling game Remnant: From the Ashes that pits survivors of humanity against new deadly creatures and god-like bosses
https://www.youtube.com/watch?v=zU6_2QnhP3U&ab_channel=Remnant2


https://steamcommunity.com/groups/indieg...0461352563

Print this item

  (Free Game Key) Homeworld: Deserts of Kharak - Free Epic Game
Posted by: xSicKxBot - 08-25-2023, 06:15 AM - Forum: Deals or Specials - No Replies

(Free Game Key) Homeworld: Deserts of Kharak - Free Epic Game

To grab the games for free:

❤️ Homeworld: Deserts of Kharak
- https://store.epicgames.com/p/homeworld-deserts-of-kharak

- Click on the GET Button
- Verify that the price is zero
- Click on the Place Order Button
- That's it, the game will be added to you Epic Games Account

Not available in South Korea

This game is free to keep if claimed by Augusts 31st , 2023 5:00 PM or in a day

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: HumbleBundle Partner[www.humblebundle.com] Fanatical Affiliate[www.fanatical.com]


https://steamcommunity.com/groups/GrabFr...3724404360

Print this item

  PC - Quake II - Enhanced Edition
Posted by: xSicKxBot - 08-25-2023, 06:15 AM - Forum: New Game Releases - No Replies

PC - Quake II - Enhanced Edition



As humanity’s last hope, it’s up to you to stop the wicked Strogg’s warpath before it twists mankind into mechanical horrors. The odds are stacked against you on a hostile alien planet teeming with enemy forces, but so long as you have ammo and a pulse, it’s not over! Battle hordes of cybernetic creatures in blistering FPS combat, strafing through Quake II’s campaign with an iconic arsenal of bullets, rockets and shells. Enjoy Quake II’s legendary gameplay, preserved and complete with the original soundtrack by Sonic Mayhem, now enhanced with widescreen support, restored content previously left on the cutting room floor, visual and performance upgrades to make every muzzle flash and gib-plosion pop on-screen and even new levels. The enhanced release of Quake II comes with both expansions for the original game, Mission Pack: The Reckoning and Mission Pack: Ground Zero, adding over 30 additional single player levels and over 20 Deathmatch maps. Quake II now includes Call of the Machine, an all-new expansion created by Wolfenstein: The New Colossus developer, MachineGames. Consisting of 28 campaign levels plus a brand-new Deathmatch map, fight across time and space to find the Strogg-Maker, destroy it and change fate itself. [Bethesda]

Publisher: ZeniMax Media

Release Date: Aug 10, 2023




https://www.metacritic.com/game/pc/quake...ed-edition

Print this item

  [Tut] Check Python Version from Command Line and in Script
Posted by: xSicKxBot - 08-24-2023, 01:34 PM - Forum: Python - No Replies

[Tut] Check Python Version from Command Line and in Script

5/5 – (1 vote)

Check Python Version from Command Line


Knowing your Python version is vital for running programs that may be incompatible with a certain version. Checking the Python version from the command line is simple and can be done using your operating system’s built-in tools.

Windows Command Prompt


In Windows, you can use PowerShell to check your Python version. Open PowerShell by pressing Win+R, typing powershell, and then pressing Enter. Once PowerShell is open, type the following command:

python --version

This command will return the Python version installed on your Windows system. If you have both Python 2 and Python 3 installed, you can use the following command to check the Python 3 version:

python3 --version

macOS Terminal


To check the Python version in macOS, open the Terminal by going to Finder, clicking on Applications, and then navigating to Utilities > Terminal. Once the Terminal is open, type the following command to check your Python version:

python --version

Alternatively, if you have Python 3 installed, use the following command to check the Python 3 version:

python3 --version

Linux Terminal


In Linux, open a terminal window and type the following command to check your Python version:

python --version

For Python 3, use the following command:

python3 --version

It is also possible to check the Python version within a script using the sys module:

import sys
print(sys.version)

This code snippet will print the Python version currently being used to run the script. It can be helpful in identifying version-related issues when debugging your code.

Check Python Version in Script


Using Sys Module



The sys module allows you to access your Python version within a script. To obtain the version, simply import the sys module and use the sys.version_info attribute. This attribute returns a tuple containing the major, minor, and micro version numbers, as well as the release level and serial number.

Here is a quick example:

import sys
version_info = sys.version_info
print(f"Python version: {version_info.major}.{version_info.minor}.{version_info.micro}")
# Output: Python version: 3.9.5

You can also use sys.version to get the Python version as a string, which includes additional information about the build. For example:

import sys
version = sys.version
print(f"Python version: {version.split()[0]}")

These methods work for both Python 2 and Python 3.

Using Platform Module



Another way to check the Python version in a script is using the platform module. The platform.python_version() function returns the version as a string, while platform.python_version_tuple() returns it as a tuple.

Here’s an example of how to use these functions:

import platform
version = platform.python_version()
version_tuple = platform.python_version_tuple()
print(f"Python version: {version}")
print(f"Python version (tuple): {version_tuple}")

Both the sys and platform methods allow you to easily check your python version in your scripts. By utilizing these modules, you can ensure that your script is running on the correct version of Python, or even tailor your script to work with multiple versions.

Python Version Components


Python versions are composed of several components that help developers understand the evolution of the language and maintain their projects accordingly. In this section, we will explore the major components, including Major Version, Minor Version, and Micro Version.

Major Version


The Major Version denotes the most significant changes in the language, often introducing new features or language elements that are not backwards compatible. Python currently has two major versions in widespread use: Python 2 and Python 3. The transition from Python 2 to Python 3 was a significant change, with many libraries and applications needing updates to ensure compatibility.

For example, to check the major version of your Python interpreter, you can use the following code snippet:

import sys
print(sys.version_info.major)

Minor Version


The Minor Version represents smaller updates and improvements to the language. These changes are typically backwards compatible, and they introduce bug fixes, performance enhancements, and minor features. For example, Python 3.6 introduced formatted string literals (f-strings) to improve string manipulation, while Python 3.7 enhanced asynchronous functionality with the asyncio module.

You can check the minor version of your Python interpreter with this code snippet:

import sys
print(sys.version_info.minor)

Micro Version


The Micro Version is the smallest level of changes, focused on addressing specific bugs, security vulnerabilities, or minor refinements. These updates should be fully backwards compatible, ensuring that your code continues to work as expected. The micro version is useful for package maintainers and developers who need precise control over their dependencies.

To find out the micro version of your Python interpreter, use the following code snippet:

import sys
print(sys.version_info.micro)

In summary, Python versions are a combination of major, minor, and micro components that provide insight into the evolution of the language. The version number is available as both a tuple and a string, representing release levels and serial versions, respectively.

Working with Multiple Python Versions


Working with multiple Python versions on different operating systems like mac, Windows, and Linux is often required when developing applications or scripts. Knowing how to select a specific Python interpreter and check the version of Python in use is essential for ensuring compatibility and preventing errors.

Selecting a Specific Python Interpreter


In order to select a specific Python interpreter, you can use the command line or terminal on your operating system. For instance, on Windows, you can start the Anaconda Prompt by searching for it in the Start menu, and on Linux or macOS, simply open the terminal or shell.

Once you have the terminal or command prompt open, you can use the python command followed by the specific version number you want to use, such as python2 or python3. For example, if you want to run a script named example_script.py with Python 3, you would enter python3 example_script.py in the terminal.

Note: Make sure you have the desired Python version installed on your system before attempting to select a specific interpreter.

To determine which Python version is currently running your script, you can use the sys module. In your script, you will need to import sys and then use the sys.version attribute to obtain information about the currently active Python interpreter.

Here’s an example that shows the Python version in use:

import sys
print("Python version in use:", sys.version.split()[0])

For a more platform-independent way to obtain the Python version, you can use the platform module. First, import platform, and then use the platform.python_version() function, like this:

import platform
print("Python version in use:", platform.python_version())

In conclusion, managing multiple Python versions can be straightforward when you know how to select a specific interpreter and obtain the currently active Python version. This knowledge is crucial for ensuring compatibility and preventing errors in your development process.

? Recommended: How To Run Multiple Python Versions On Windows?

Python Version Compatibility


Python, one of the most widely-used programming languages, has two major versions: Python2 and Python3. Understanding and checking their compatibility ensures that your code runs as intended across different environments.

To check the Python version via the command line, open the terminal (Linux, Ubuntu) or command prompt (Windows), and run the following command:

python --version

Alternatively, you can use the shorthand:

python -V

For checking the Python version within a script, you can use the sys module. In the following example, the major and minor version numbers are obtained using sys.version_info:

import sys
version_info = sys.version_info
print(f"Python {version_info.major}.{version_info.minor} is running this script.")

Compatibility between Python2 and Python3 is essential for maintaining codebases and leveraging pre-existing libraries. The 2to3 tool checks for compatibility by identifying the necessary transitions from Python2 to Python3 syntax.

To determine if a piece of code is Python3-compatible, run the following command:

2to3 your_python_file.py

Python packages typically declare their compatibility with specific Python versions. Reviewing the package documentation or its setup.py file provides insight into supported Python versions. To determine if a package is compatible with your Python environment, you can check the package’s release history on its project page and verify the meta-information for different versions.

When using Ubuntu or other Linux distributions, Python is often pre-installed. To ensure compatibility between different software components and programming languages (like gcc), regularly verify and update your installed Python versions.

Comparing Python Versions


When working with Python, it’s essential to know which version you are using. Different versions can have different syntax and functionality. You can compare the Python version numbers using the command line or within a script.

To check your Python version from the command line, you can run the command python --version or python3 --version. This will display the version number of the Python interpreter installed on your system.

In case you are working with multiple Python versions, it’s important to compare them to ensure compatibility. You can use the sys.version_info tuple, which contains the major, minor, and micro version numbers of your Python interpreter. Here’s an example:

import sys if sys.version_info < (3, 0, 0): print("You are using Python 2.x")
else: print("You are using Python 3.x or higher")

This code snippet compares the current Python version to a specific one (3.0.0) and prints a message to the shell depending on the outcome of the comparison.

In addition to Python, other programming languages like C++ can also have different versions. It’s important to be aware of the version number, as it affects the language’s features and compatibility.

Remember to always verify and compare Python version numbers before executing complex scripts or installing libraries, since a mismatch can lead to errors and unexpected behavior. By using the command line or programmatically checking the version in your script, you can ensure smooth and error-free development.

Frequently Asked Questions


How to find Python version in command line?


You can find the Python version in the command line by running the following command:

python --version

Or:

python -V

This command will display the Python version installed on your system.

How to check for Python version in a script?


To check for the Python version in a script, you can use the sys module. Here’s an example:

import sys
print("Python version")
print(sys.version)
print("Version info.")
print(sys.version_info)

This code will print the Python version and version information when you run the script.

Ways to determine Python version in prompt?


As mentioned earlier, you can use the python --version or python -V command in the command prompt to determine the Python version. Additionally, you can run:

python -c "import sys; print(sys.version)"

This will run a one-liner that imports the sys module and prints the Python version.

Is Python installed? How to verify from command line?


To verify if Python is installed on your system, simply run the python --version or python -V command in the command prompt. If Python is installed, it will display the version number. If it’s not installed, you will receive an error message or a command not found message.

Verifying Python version in Anaconda environment?


To verify the Python version in an Anaconda environment, first activate the environment with conda activate <environment_name>. Next, run the python --version or python -V command as mentioned earlier.

Determining Python version programmatically?


Determining the Python version programmatically can be done using the sys module. As shown in the second question, you can use the following code snippet:

import sys
print("Python version: ", sys.version)
print("Version info: ", sys.version_info)

This code will print the Python version and version information when executed.


? Recommended: HOW TO CHECK YOUR PYTHON VERSION

The post Check Python Version from Command Line and in Script appeared first on Be on the Right Side of Change.



https://www.sickgaming.net/blog/2023/08/...in-script/

Print this item

  [Tut] Upload and Display Image in PHP
Posted by: xSicKxBot - 08-24-2023, 01:33 PM - Forum: PHP Development - No Replies

[Tut] Upload and Display Image in PHP

by Vincy. Last modified on July 5th, 2023.

PHP upload is a single-line, built-in function invocation. Any user inputs, especially files, can not be processed without proper filtering. Why? Because people may upload harmful files to the server.

After file upload, the status has to be shown in the UI as an acknowledgment. Otherwise, showing the uploaded image’s preview is the best way of acknowledging the end user.

View Demo
Earlier, we saw how to show the preview of images extracted from a remote URL.

This article will provide a short and easy example in PHP to upload and display images.

upload and display image php

Steps to upload and display the image preview on the browser


  1. Show an image upload option in an HTML form.
  2. Read file data from the form and set the upload target.
  3. Validate the file type size before uploading to the server.
  4. Call the PHP upload function to save the file to the target.
  5. Display the uploaded image on the browser

1. Show an image upload option in an HTML form


This code is to show an HTML form with a file input to the user. This form is with enctype="multipart/form-data" attribute. This attribute is for uploading the file binary to be accessible on the PHP side.

<form action="" method="post" enctype="multipart/form-data"> <div class="row"> <input type="file" name="image" required> <input type="submit" name="submit" value="Upload"> </div>
</form>

Read file data from the form and set the upload target


This section shows a primary PHP condition to check if the form is posted and the file binary is not empty.

Once these conditions return true, further steps will be taken for execution.

Once the image is posted, it sets the target directory path to upload. The variable $uploadOK is a custom flag to allow the PHP file upload.

If the validation returns false, this $uploadOK variable will be turned to 0 and stop uploading.

<?php
if (isset($_POST["submit"])) { // Check image using getimagesize function and get size // if a valid number is got then uploaded file is an image if (isset($_FILES["image"])) { // directory name to store the uploaded image files // this should have sufficient read/write/execute permissions // if not already exists, please create it in the root of the // project folder $targetDir = "uploads/"; $targetFile = $targetDir . basename($_FILES["image"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); // Validation here }
}
?>

Validate the file type size before uploading to the server


This example applies three types of validation criteria on the server side.

  1. Check if the uploaded file is an image.
  2. Check if the image has the accepted size limit (0.5 MB).
  3. Check if the image has the allowed extension (jpeg and png).
<?php
// Check image using getimagesize function and get size // if a valid number is got then uploaded file is an image if (isset($_FILES["image"])) { // directory name to store the uploaded image files // this should have sufficient read/write/execute permissions // if not already exists, please create it in the root of the // project folder $targetDir = "uploads/"; $targetFile = $targetDir . basename($_FILES["image"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); $check = getimagesize($_FILES["image"]["tmp_name"]); if ($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if the file already exists in the same path if (file_exists($targetFile)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size and throw error if it is greater than // the predefined value, here it is 500000 if ($_FILES["image"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Check for uploaded file formats and allow only // jpg, png, jpeg and gif // If you want to allow more formats, declare it here if ( $imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; }
?>

4. Call the PHP upload function to save the file to the target


Once the validation is completed, then the PHP move_uploaded_file() the function is called.

It copies the file from the temporary path to the target direct set in step 1.

<?php
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) { echo "Sorry, your file was not uploaded.";
} else { if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFile)) { echo "The file " . htmlspecialchars(basename($_FILES["image"]["name"])) . " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; }
}
?>

5. Display the uploaded image on the browser.


This section shows the image preview by setting the source path.

Before setting the preview source, this code ensures the upload status is ‘true.’

<h1>Display uploaded Image:</h1>
<?php if (isset($_FILES["image"]) && $uploadOk == 1) : ?> <img src="<?php echo $targetFile; ?>" alt="Uploaded Image">
<?php endif; ?>

Create a directory called “uploads” in the root directory of the downloaded example project. Uploaded images will be stored in this folder.

Note: The “uploads” directory should have sufficient file permissions.
View Demo Download

↑ Back to Top



https://www.sickgaming.net/blog/2023/07/...ge-in-php/

Print this item

 
Latest Threads
Insta360 Camera Free Ship...
Last Post: tomen44
2 hours ago
Get Insta360 X5 at 20% Of...
Last Post: tomen44
2 hours ago
5% Discount on Insta360 X...
Last Post: tomen44
2 hours ago
Insta360 Sale USA – Get F...
Last Post: tomen44
2 hours ago
Insta360 USA Coupon [INRS...
Last Post: tomen44
3 hours ago
Insta360 USA Coupon [INRS...
Last Post: tomen44
3 hours ago
Insta360 X5 Deal – Free S...
Last Post: tomen44
3 hours ago
Insta360 July 2026 Offer ...
Last Post: tomen44
3 hours ago
News - Subnautica 2’s Leg...
Last Post: xSicKxBot
10 hours ago
Redacted T6 Nightly Offli...
Last Post: Ngixk0
Yesterday, 03:21 PM

Forum software by © MyBB Theme © iAndrew 2016