Microsoft acquires Bethesda, creators of The Elder Scrolls, Fallout and Doom
Microsoft just announced its purchase of ZeniMax Media, parent company of Bethesda Softworks, for USD 7.5 billion. This deal means that Bethesda Game Studios, id Software, ZeniMax Online Studios, Arkane, MachineGames, Tango Gameworks, Alpha Dog, and Roundhouse Studios are now part of the Xbox family. It gives Microsoft ownership of franchises such as The Elder Scrolls, Fallout, Wolfenstein, DOOM, Dishonored, Quake, Starfield, and more.
Bethesda has been a big supporter of Xbox Game Pass for some time now, and Microsoft will be adding Bethesda’s beloved franchises to Xbox Game Pass for console and PC. You can also look forward to some highly anticipated titles such as Starfield, an upcoming space RPG in development by Bethesda Game Studios, that will be available day one on Game Pass, and many yet to be announced titles.
It will be interesting to see how this affects Nintendo Switch, as many popular Xbox titles have recently launched for the console, including Ori and the Will of the Wisps, which was revealed during the Nintendo Direct Mini recently. Hopefully, this will lead to more Bethesda titles coming to the console.
Video: The World Ends With You’s Upcoming Anime Series Gets A New Trailer
A new trailer has been released for The World Ends With You: The Animation, a new, upcoming anime series based on the video game.
As you may know already, the show will be based on the original Nintendo DS title from 2007, with members of the original development team returning to bring the story to life. A teaser trailer was released back in July, but this new video gives us another look at what we can expect to see.
Here’s an overview and credit list (thanks, Gematsu):
Race through the streets of Shibuya and survive the seven-day Reapers’ Game!
Neku awakens in the middle of Shibuya’s bustling Scramble Crossing with no memory of how he got there. Little does he know he’s been transported to an alternate plane of existence known as the Underground (UG). Now an unwilling participant in the mysterious “Reapers’ Game,” Neku must partner up with a girl named Shiki in order to survive. Together, they complete missions and defeat monsters known as “Noise” as they gradually uncover the true nature of this twisted Game.
“There’s only one way to stay alive in Shibuya: trust your partner.” Will they survive the Reapers’ Game?
Staff –Based on the original story:The World Ends with You (Square Enix) – Director: Kazuya Ichikawa (Domerica) – Screenwriter: Midori Goto (Sanzigen) – Character Design: Tetsuya Nomura & Gen Kobayashi (Square Enix) – Music: Takeharu Ishimoto (Thrill) – Production: Domerica x Shin-Ei Animation
The anime is scheduled to air internationally in 2021.
Are you a fan of the series? Will you be checking out the show? Let us know in the comments.
Xbox Series X And S Make It Much Easier To Take Screenshots And Videos
Xbox One's screenshot and video capture options have always required an extra step of input from users, as the standard controller doesn't have a button dedicated solely to that task. In comparison, the PlayStation 4's DualShock 4 controller has had a much simpler solution in place since it debuted in 2014: A Share button, that can be used to record gameplay, take screenshots, and start a livestream of a game.
While the Xbox App, formerly known as SmartGlass, gave users a more comprehensive solution to this issue last year in February, it wouldn't be until December 2019's reveal of the Xbox Series X that a redesigned controller with its own Share button for easier content creation would be confirmed. In a new trailer showing off this feature, Microsoft has revealed how users will be able to capture gaming moments through the Share button on Xbox One, Xbox Series X, and Series S consoles.
The new Xbox controller can grab a screenshot with a simple button press, while briefly holding it will record gameplay. Once the content has been captured, it can be uploaded to Twitter, Facebook, WhatsApp, and Instagram. Users will also be able to share content in their Xbox activity feed with their friends. Microsoft says that the new sharing experience that has been built will "make it easier than ever to share your game clips and screenshots with friends from your mobile phone."
In the next part in our going look at key extensions in the Unity Game Dev Humble Bundle, today we are looking at Peek from Ludiq. In previous features we have looked at UModeler and Clayxels if you are interested in learning more.
Peek is a powerful add-on the greatly changes the way you work with Unity, including features like:
Dynamic toolbars the replace the requirement for the Inspector windows
Pop up support on Ctrl+F replacing the need for the Hierarchy window
Sticky drag and drop
Quick reference inspection
Creator to quickly create and place objects and instances in your scene
Multi-object grouping
You can see Peek and most of these features in action in the video below (or here on Odysee). Peek is regularly $60 on the Unity Asset Store and is half that price (with dozens of other assets and games) in the current Bundle, expiring in 9 days.
Posted by: xSicKxBot - 09-21-2020, 03:22 PM - Forum: Windows
- No Replies
Microsoft will replenish more water than it consumes by 2030
Water is essential to life. We depend on it for our survival. The basic need has shaped how human societies have advanced over time. Explorers from pre-Columbian times and the age of antiquity to NASA have lived by the motto “follow the water” as they have sought and continue to seek to discover new opportunities for the expansion of human civilization.
While water is plentiful – covering 70% of the Earth’s surface – 97% of this water is saline, located in our oceans, and not fit to drink or use for crops. The world’s fresh water is not equally distributed or accessible and is found disproportionately in places where people do not live. And as human civilization has expanded, we have reached the point globally where humanity depletes the available freshwater supply at a rate of 4.3 trillion cubic meters every year – the majority of which goes to agricultural and industrial uses.
This needs to change. That’s why we’re announcing an ambitious commitment for Microsoft to be water positive for our direct operations by 2030. We’re tackling our water consumption in two ways: reducing our water use intensity – or the water we use per megawatt of energy used for our operations – and replenishing water in the water- stressed regions we operate. This means that by 2030 Microsoft will replenish more water than it consumes on a global basis.
As with our other environmental commitments, we hope these steps will help contribute to a growing movement to address the world’s sustainability needs.
More momentum is clearly needed. Today, according to United Nations Water, more than two billion people lack access to safe drinking water. And climate change is only intensifying this water shortage. The U.N. estimates that one in four people may live in a country affected by chronic shortages of freshwater by 2050. According to the World Bank, this climate-induced reduction in freshwater availability, coupled with increased demand, could reduce water availability in cities by more than 66% by 2050.
Getting ahead of the world’s water crisis will require a reduction in the amount of water humans use to operate economies and societies, as well as a concerted effort to ensure there is sufficient water in the places it is needed most. This will require a transformation in the way we manage our water systems and a concerted effort for all organizations to account for and balance their water use. As a global technology company Microsoft is prepared to act on both accounts, taking responsibility for our own water use and partnering on technology platforms to help others do the same.
Over the past year we have committed Microsoft to becoming a carbon negative, zero waste company that is building a new planetary computing platform to transform the way we monitor, model, and ultimately manage Earth’s natural systems. Our pledge today to become water positive by 2030 adds a fourth pillar to this work. And as in our other areas, we’re committed not only to setting ambitious goals for ourselves but using technology to better help our customers to do the same.
Water positive by 2030
By 2030 we will be water positive, meaning we will replenish more water than we use. We’ll do this by putting back more water in stressed basins than our global water consumption across all basins. The amount returned will be determined by how much water we use and how stressed the basin is.
Our replenishment strategy will include investments in projects such as wetland restoration and the removal of impervious surfaces like asphalt, which will help replenish water back into the basins that need it most. We will focus our replenishment efforts on roughly 40 highly stressed basins where we have operations. This reflects a science-based assessment of the world’s water basins. The majority of the world’s freshwater is divided into 16,396 basins, each of which has been assigned a “baseline water stress” score by the World Resources Institute (WRI), a leading nonprofit global research organization that focuses on natural resources. A basin is considered “highly stressed” if the amount of water withdrawn exceeds 40% of the renewable supply. Globally there are 4,717 basins that fall into this category.
All of this work will build on our ongoing investments, and advances water reduction and replenishment across our operations. This includes a sustainability design standard across Microsoft that requires water conservation at all locations globally. These include:
Our new Silicon Valley campus, opening later this year in California, features an on-site rainwater collection system and waste treatment plant to ensure 100% of the site’s non-potable water comes from onsite recycled sources. An integrated water management system will manage and reuse rainwater and wastewater. By recycling our water, the campus will save an estimated 4.3 million gallons of potable water each year.
Nearly halfway around the world, our new Herzliya, Israel campus features water-efficient plumbing fixtures that drive up water conservation by 35%. In addition, 100% of water collected from air conditioners will be used to water plants on-site.
In India, our newest building on our Hyderabad campus will support 100% treatment and reuse of wastewater on-site for landscaping, flushing, and cooling tower makeup.
At our headquarters redevelopment in Puget Sound, all new office buildings will reuse harvested rainwater in flush fixtures and low-flow systems, which is projected to save more than 5.8 million gallons annually.
At our new datacenter region in Arizona, available for use in 2021, we are innovating ways to reduce our water use intensity and replenish water in this highly stressed region. We will use zero water for cooling for more than half the year, leveraging a method called adiabatic cooling, which uses outside air instead of water for cooling when temperatures are below 85 degrees Fahrenheit. When temperatures are above 85 degrees, an evaporative cooling system is used, acting like a “swamp cooler” that you find in residential homes. This system is highly efficient, using less electricity and up to 90% less water than other water-based cooling systems, such as cooling towers. We are also partnering with First Solar to provide solar energy rather than traditional electricity generation, which is expected to save more than 350 million liters of water annually.
Our reduction in water use intensity and our replenishment commitments address the key issue of water availability, which is the amount of water that can be used to meet demand. That, however, is only part of the challenge. Equally important is the issue of accessibility, which is the supply of safe drinking water and sanitation. That is why we are partnering with nongovernmental organizations (NGOs) to ensure more than 1.5 million people have access to clean drinking and sanitation water. We’ll focus this work in seven countries. We’ll start by partnering with Water.org, a leading global nonprofit focused on underserved communities, to help people in Brazil, India, Indonesia and Mexico. We’ll then expand this work with partners in China, Malaysia and South Africa.
Digitizing water data
We will also use our technology to better understand where water stress is emerging and optimize water replenishment investments across a region. Through our AI for Earth program we are supporting projects in each of these areas:
Vector Center works with governments and companies around the world to better understand the impact of water availability and accessibility. One of the challenges it addresses is water risk and scarcity in urban communities where data is still often analog, printed and stored in stacks. It is digitizing data and has developed a platform called the Perception Reality Engine on Azure to collect, correlate and analyze data and produce an overall picture of what’s actually happening in real time, to better see how to forestall the threat of when water may not be available. It also can provide a historic view of water in a particular area. The Perception Reality Engine uses data on rainfall, surface water amounts, plant growth and more to map water availability around the world and flag where crises are occurring or may soon occur. It also overlays this information with news sources and social media to determine where the public perception is different than reality so governance, education and behavior changes can be made before water runs out in a region.
The Freshwater Trust, a nonprofit that protects and restores freshwater ecosystems, and Upstream Tech, a company that develops technological solutions for water conservation, worked together to develop a tool called the BasinScout Platform. It uses satellite data, data about crop growth and farming practices, and applies machine learning to assess field-level agricultural practices and their impact on water resources at scale, including scenarios about how to be more water- and cost-efficient. This helps conserve and protect the water basins that are main sources of the public’s water supply.
Leadership Counsel for Justice and Accountability is a California nonprofit focused on land use and transportation in underserved communities. It is working to address the challenge of drinking water availability in California’s Central Valley. About 1.5 million people in the region rely on private domestic wells for drinking water, and many of these wells often fail during drought or due to groundwater management issues. The Leadership Counsel is using AI to predict domestic well failure resulting from groundwater changes and resulting drinking water shortages. They’re providing that information to local agencies that can use this information to prevent well failure and improve water resource management and planning.
Climate Innovation Fund investment: Emerald Technology Ventures
Microsoft’s Climate Innovation Fund is investing $10 million in the Emerald Technology Ventures’ $100 million Global Impact Fund, whose investors also include Temasek, Ecolab and SKion. The fund will partner with early- to expansion-stage companies from around the world, driving innovation and its adoption in water technologies. It will focus on pressing challenges, including conserving water resources, improving water efficiency and quality, avoiding carbon emissions in water treatment, and adapting to climate change. This fund is one of the few funds solely focused on water strategy.
This is the third investment the Climate Innovation Fund has made in one of company’s four sustainability focus areas. The first was focused on carbon and the second on waste.
Empowering our customers
Microsoft is also developing solutions to help customers understand water-related risks due to climate change; use data to reduce water use and make smarter decisions about water; and, improve water quality and conservation. Technologies like IoT and AI are playing a critical role in improving water quality and water efficiency. For example, the Azure IoT Central government app templates includes remote, real-time water quality monitoring and water consumption monitoring, geared toward reducing water consumption.
Ecolab, a leading global provider of water, hygiene and energy technologies and services, is a Microsoft customer and a partner that is using data and technology to help its customers be more water efficient and use less water across their operations. The data Ecolab collects from more than 42,000 connected smart water sensors around the world is used to make informed recommendations to improve processes and reduce water consumption. It leads to a “virtuous cycle” of less water, better results and much lower operating costs. Using Microsoft technologies like Azure, Azure Machine Learning, Power BI and more, Ecolab is accelerating net zero water usage around the world in sectors including energy, agriculture, food and beverage, manufacturing and hospitality.
Schneider Electric (SE) provides energy and automation digital solutions for efficiency and sustainability; combining world-leading energy technologies, real-time automation, software and services into integration solutions. They have recently co-innovated solutions on Azure to improve water and wastewater management along the water cycle through smart water technology and services for optimized water and waste operations, water and energy, safety and enterprise sustainability. This includes recent work to help restore the water quality of the Bogotá River with the expansion of the Salitre II wastewater treatment plant. Working with the Bogotá Colombia Water treatment plant, the largest in Colombia and under execution by Aqualia, new digital technologies are making the plant more efficient. The Bogotá River is polluted, and this is threatening the environment and health of the 8 million inhabitants of Bogota. The wastewater treatment plant is an important part of the remediation efforts.
Grundfos is a global water technology company headquartered out of Bjerringbro, Denmark. They pioneer solutions to the world’s water and climate challenges improve quality of life for people. Grundfos utilizes Microsoft to support their business’ transformation in digital and water solutions with the expected outcomes of improving customer satisfaction, increasing innovation and operational excellence. Two ambitious water goals are to provide safely managed drinking water to 300 million people in need and save 50 billion cubic meters of consumable freshwater by 2030, which is why a lot of innovation is going on. To provide water also means to reduce the amount of energy needed to heat our cities – enter the Grundfos iGRID system built on Azure. Azure services, such as the IoT Hub, are utilized by iGRID to optimize heat distribution in cities to save energy. Grundfos can reduce heat losses by 20%, which means iGRID on Azure will be reducing the energy usage in our cities, improving the longevity of our existing networks and lowering the costs to the everyday citizen.
Seequent is a New Zealand-based Microsoft customer and partner. They rely on Azure to drive their geospatial and geoscience work, including important work to address water quality and quantity with the Water Replenishment District (WRD), the largest groundwater agency in the state of California. WRD’s service area covers a 420-square-mile region of southern Los Angeles County and accounts for approximately half of the region’s water supply. The WRD is using Seequent’s Leapfrog Works to create 3D models of the local water basins, creating better understanding of groundwater flow and identifying contamination. These models are helping WRD maintain their Water Independence Now Program, which has made the region sustainable using local resources including advanced treated recycled water to replenish groundwater supplies.
Water Resilience Coalition
We understand that no one company or organization can solve the world’s water crisis. The private sector also has a significant opportunity to have a positive impact on water availability and accessibility: 150 of the world’s biggest companies have the potential to influence one-third of global freshwater use. Launched earlier this year, the Water Resilience Coalition is an initiative of the United Nations Global Compact CEO Water Mandate. Founded by seven companies, including Microsoft, the coalition has since grown to 16 industry-leading corporations, all of whom have pledged to work collectively on water issues. We are working together to identify priority basins for collective action and to set targets for improving conditions in those basins. As part of our water goals, we will partner with Water Resilience Coalition members to co-invest in availability, accessibility and quality projects in water-stressed basins and we will actively recruit other companies to join us in this important coalition.
Policy
Governments also play a fundamental role in ensuring the availability of safe, clean drinking water, maintaining and expanding water infrastructure, protecting critical water ecosystems, and responding to water crises. We will use our voice at the local, national and global levels on public policy that would increase water access and availability and improve quality.
Improving Data in Water Stressed Areas: We can’t solve a problem that we don’t fully understand. Governments ought to develop more accurate and up-to-date assessment of ground and surface water levels and how they are changing over time. This data can help local stakeholders calculate and forecast demand and supply balances; track water quality; facilitate disaster prevention and early warning systems; and ultimately develop innovative solutions. We are encouraged to see the EU’s plans to create a Common European Green Deal data space, as part of the European Strategy for Data, that aims to harness the potential of environmental data to help achieve the EU’s ambitious climate objectives. To support such efforts, Microsoft will work with partners to deploy tools that provide better hydrologic data that enable enhanced water management.
Upgrading Water Infrastructure: We need governments to invest in upgrading and expanding water infrastructure. This is critical to provide safe drinking water, treat storm and wastewater, manage water levels, and protect against climate impacts, particularly in the most vulnerable communities. These investments can also provide much needed job creation. National governments should look for opportunities to integrate water infrastructure into COVID-19 recovery packages and foster innovative solutions. We applaud the EU for including water-related green infrastructure in the InvestEU Programme as well as recent bipartisan effort by the U.S. Congress to consider reauthorization of critical water infrastructure funding. We will encourage national governments to prioritize these critical investments in the months and years ahead.
Integrating water into climate strategies: Water is the primary means through which climate change will be experienced. As such, we need government to address climate and water challenges in a more integrated way. One way to do this is through the long-term goals that countries set as part of their national climate plans or Intended Nationally Determined Contributions (INDCs) under the Paris climate agreements. As national governments work to update their 2030 climate plans, in advance of COP26, the annual UN climate conference, in 2021, they should include an explicit water-related target in their climate mitigation and adaptation strategies.
To help advance these policy efforts, we will join WaterEurope to promote smart water solutions and will encourage our other trade associations and advocacy partners in the U.S. and EU to play a more active role in advocating these policies.
Enlisting our employees
As we have with each of our previous sustainability commitments, we will enlist our employees by inviting them to participate in volunteer opportunities associated with the replenishment projects we will be investing in. Our employees have volunteered with NGOs we’re partnering with on water replenishment projects, including the restoration of Lake Sembakkam in Chennai, India; restoration of Crow Creek in Cheyenne, Wyoming; and, habitat restoration along the Red River in Fargo, North Dakota. In regions without active replenishment projects, we will provide information about volunteer opportunities with nonprofits working on water projects in their communities.
While our commitments focus on fresh water we recognize the need to protect the world’s oceans, which generate more than 50% of the world’s oxygen, absorb half the carbon produced and account for 80% of the planet’s biodiversity. Oceans also are critical to our globally economy and food security, with more than 100 million households dependent on the fisheries for their livelihoods, and 3 billion dependent on seafood as their primary protein.
Protecting the world’s oceans
The Organization for Economic Co-operation and Development (OECD) estimates that by 2030 the value of the ocean economy could exceed $3 trillion and more than 40 million jobs. To realize this potential economic impact, the private and public sectors and civil society must work together to reverse declining ocean biodiversity resulting from climate change, pollution and overexploitation. That requires good data, governance and policies, and technological innovations like smart sensors, autonomous robots, data analytics and AI to better monitor, model and manage oceans.
That’s why we’re joining the World Economic Forum’s Center for the Fourth Industrial Revolution Network for ocean innovation and technology in Norway (C4IR Ocean). It’s dedicated to using data, technology and governance frameworks to protect the world’s oceans and increase the sustainability of ocean-based industries.
Unlike roads, oceans have not been adequately mapped, so we are not making informed decisions. We’re one of the organizations working with C4IR Ocean on its Ocean Data Platform. This global, open-source platform gives data scientists, app developers and marine spatial planners access to data coming from historic and real-time data sources to develop solutions to improve ocean health.
***
Our mission is to empower every person and organization on the planet to achieve more. We believe that the purpose of business – and our responsibility – is to produce profitable solutions to the problems of people and planet. That’s why we’re working every day with our customers, partners, NGOs and others around the world to address the climate crisis. What’s good for the planet is ultimately good for Microsoft.
Vagrant is a brilliant tool, used by DevOps professionals, coders, sysadmins and regular geeks to stand up repeatable infrastructure for development and testing. From their website:
Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.
If you are already familiar with the basics of Vagrant, the documentation provides a better reference build for all available features and internals.
Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.
This guide will walk through the steps necessary to get Vagrant working on a Fedora-based machine.
I started with a minimal install of Fedora Server as this reduces the memory footprint of the host OS, but if you already have a working Fedora machine, either Server or Workstation, then this should still work.
$ mkdir vagrant-test
$ cd vagrant-test
$ vi Vagrantfile
Vagrant.configure("2") do |config| config.vm.box = "fedora/32-cloud-base"
end
Note the capitalisation of the file name and in the file itself.
Check the file:
vagrant status
Current machine states: default not created (libvirt) The Libvirt domain is not created. Run 'vagrant up' to create it.
Start the box:
vagrant up
Connect to your new machine:
vagrant ssh
That’s it – you now have Vagrant working on your Fedora machine.
To stop the machine, use vagrant halt. This simply halts the machine but leaves the VM and disk in place. To shut it down and delete it use vagrant destroy. This will remove the whole machine and any changes you’ve made in it.
Next steps
You don’t need to download boxes before issuing the vagrant up command – you can specify the box and the provider in the Vagrantfile directly and Vagrant will download it if it’s not already there. Below is an example which also sets the amount memory and number of CPUs:
# -*- mode: ruby -*-
# vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "fedora/32-cloud-base" config.vm.provider :libvirt do |libvirt| libvirt.cpus = 1 libvirt.memory = 1024 end
end
For more information on using Vagrant, creating your own machines and using different boxes, see the official documentation at https://www.vagrantup.com/docs
There is a huge repository of boxes ready to download and use, and the official location for these is Vagrant Cloud – https://app.vagrantup.com/boxes/search. Some are basic operating systems and some offer complete functionality such as databases, web servers etc.
In the short time-frame since the leak and release of Super Mario 3D All-Stars, dataminers have been discovering more and more about this 35th-anniversary collection each day.
The latest finding once again comes from OatmealDome. This time, they believe they’ve uncovered additional “GPU features” in the GameCube and Wii emulator within the collection. They go on to suggest how it could be a sign of more to come (possibly other games from these generations), but can’t guarantee anything.
YouTuber Modern Vintage Gamer also speculated how this could lead to more games:
“Given the inclusion of these two GPU features in the emulation layer, while right now there is no proof of anything – and I want to be very clear that this is just speculation, it does kind of suggest though, that the reason why NERD decided to build an emulation layer for Mario 3D All-Stars rather than just port code, is not because it’s a ‘lazy port’ but because they wanted to build an emulation layer that is reusable, and they want to use it for up and coming titles.”
“The cost and time to port older games would be significant, verses applying an emulation layer just to other games.”
“I think the emulation layer that NERD has developed is going to be utilised for game-specific enhancements and game-specific remasters to the Nintendo Switch.”
“Ultimately, they’ve gone down the right path and it really opens up the door for older games to be remastered.”
What do you make of these latest findings? Hoping it leads to something more? Tell us down below.
Python’s dictionary data structure is one of the most powerful, most underutilized data structures in Python. Why? Because checking membership is more efficient for dictionaries than for lists, while accessing elements is easier for dictionaries than for sets.
In this tutorial, you’ll learn how to perform four common dictionary operations in one line of Python code. By studying these problems, you’ll not only learn how to use dictionaries in Python, but you’ll become a better coder overall. So, let’s dive into the first problem: creating a dictionary from a list in one line.
Python Create Dictionary From List in One Line
Challenge: Create a dictionary from a list in one line of Python.
Example: Say, you want to have the list indices as keys and the list elements as values.
# Given a list:
a = ['Alice', 'Liz', 'Bob'] # One-Line Statement Creating a Dict:
d = one-line-statement print(d)
# {0: 'Alice', 1: 'Liz', 2: 'Bob'}
Solution: There are multiple ways to accomplish this task. Let’s learn the most Pythonic one next:
# Given a list:
a = ['Alice', 'Liz', 'Bob'] # One-Line Statement Creating a Dict:
d = dict(enumerate(a)) print(d)
# {0: 'Alice', 1: 'Liz', 2: 'Bob'}
The one-liner dict(enumerate(a)) first creates an iterable of (index, element) tuples from the list a using the enumeratefunction. The dict()constructor than transforms this iterable of tuples to (key, value) mappings. The indextuple value becomes the new key. The element tuple value becomes the new value.
Try it yourself in our interactive code shell:
Exercise: Explore the enumerate() function further by printing its output!
Python One Line For Loop to Create Dictionary
Challenge: How to create a dictionary from all elements in a list using a single-line for loop?
Example: Say, you want to replace the following four-liner code snippet with a Python one-liner.
a = ['Alice', 'Liz', 'Bob'] data = {}
for item in a: data[item] = item
a = ['Alice', 'Liz', 'Bob'] # One-Liner Dictionary For Loop
data = {item:item for item in a} print(data)
# {'Alice': 'Alice', 'Liz': 'Liz', 'Bob': 'Bob'}
Dictionary Comprehension is a concise and memory-efficient way to create and initialize dictionaries in one line of Python code. It consists of two parts: expression and context. The expression defines how to map keys to values. The context loops over an iterable using a single-line for loop and defines which (key,value) pairs to include in the new dictionary.
You can learn about dictionary comprehension in my full video tutorial:
Challenge: How can you print a dictionary in a well-structured way using only a single line of Python code (without using multiple lines to create the output)?
Solution: Use the pretty print function!
The built-in module pprint contains the function pprint. This will ‘pretty print’ your dictionary. It sorts the keys alphabetically and prints each key-value pair on a newline.
from pprint import pprint
messy_dict = dict(z='Here is a really long key that spans a lot of text', a='here is another long key that is really too long', j='this is the final key in this dictionary') pprint(messy_dict) '''
{'a': 'here is another long key that is really too long', 'j': 'this is the final key in this dictionary', 'z': 'Here is a really long key that spans a lot of text'} '''
Printing the dictionary this way, doesn’t change the dictionary in any way but makes it more readable on the Python shell!
Iterate Over Dictionary Python One Line
Challenge: How to iterate over a dictionary in Python in one line?
Example: Say, you want to go over each (key, value) pair of a dictionary like this:
age = {'Alice': 19, 'Bob': 23, 'Frank': 53} # Iterate over dictionary (key, value) pairs
for name in age: key, value = name, age[name] print(key, value) '''
OUTPUT:
Alice 19
Bob 23
Frank 53 '''
But you want to do it in a single line of Python code! How?
Solution: Use the dict.items() method to obtain the iterable. Then, use a single-line for loop to iterate over it.
age = {'Alice': 19, 'Bob': 23, 'Frank': 53} # Iterate over dictionary (key, value) pairs
for k,v in age.items(): print(k,v) '''
OUTPUT:
Alice 19
Bob 23
Frank 53 '''
The output is the same while the code is much more concise. The items() method of a dictionary object creates an iterable of (key, value) tuple pairs from the dictionary.
Python Update Dictionary in One Line
Challenge: Given a dictionary and a (key, value) pair. The key may or may not already exist in the dictionary. How to update the dictionary in one line of Python?
Solution: Use the square bracket notation dict[key] = value to create a new mapping from key to value in the dictionary. There are two cases:
The key already existed before and was associated to the old value_old. In this case, the new value overwrites the old value_old after updating the dictionary.
The key didn’t exist before in the dictionary. In this case, it is created for the first time and associated to value.
Here’s the code:
age = {'Alice': 19, 'Bob': 23, 'Frank': 53} print(f"Alice is {age['Alice']} years old")
# Alice is 19 years old # Alice's Birthday
age['Alice'] = 20 print(f"Alice is {age['Alice']} years old")
# Alice is 20 years old
Challenge 2: But what if you want to update only if the key didn’t exist before. In other words, you don’t want to overwrite an existing mapping?
Solution: In this case, you can use the check if key in dict to differentiate the two cases:
age = {'Alice': 19, 'Bob': 23, 'Frank': 53} print(f"Alice is {age['Alice']} years old")
# Alice is 19 years old # Alice's Birthday
if 'Alice' not in age: age['Alice'] = 20 print(f"Alice is {age['Alice']} years old")
# Alice is 19 years old
Now, you may want to write this in a single line of code. You can do it the naive way:
setdefault(key[, default]) — If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None.
You can simply ignore the return value to update a key in a dictionary if it isn’t already present.
age = {'Alice': 19, 'Bob': 23, 'Frank': 53} print(f"Alice is {age['Alice']} years old")
# Alice is 19 years old # Alice's Birthday
age.setdefault('Alice', 20) print(f"Alice is {age['Alice']} years old")
# Alice is 19 years old
The age.setdefault('Alice', 20) only inserts the key 'Alice' if it isn’t already present (in which case it would associate the value 20 to it). But because it already exists, the command has no side effects and the new value does not overwrite the old one.
Where to Go From Here?
Enough theory, let’s get some practice!
To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?
Practice projects is how you sharpen your saw in coding!
Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?
Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.
Duelling mini LED suppliers could cut cost on display tech for Apple
Apple may not limit the sourcing of mini LED chips for a rumored future iPad model to just one supplier, analyst Ming-Chi Kuo suggests, with work from a second supplier on the technology potentially leading to cost savings for Apple.
Mini LED is a display technology that could help TFT screens have a better backlight than existing displays, bringing it closer to OLED in terms of contrast. While Apple has been rumored to bring the technology to market in some form of iPad, it seems Apple may already have a way to boost production.
According to TF Securities analyst Ming-Chi Kuo in a research note seen by MacRumors, supplier Epistar was previously predicted to be the only supplier of mini LED chips to Apple in 2021. However, progress made on mini LED at Sanan Optoelectronics has been rapid enough to potentially change Apple’s schedule for inclusion.
Previously, Sanan was thought to be included in the mini LED supply chain in 2022, but developments now puts Kuo’s estimate to a 2021 entry instead.
For Apple, having two suppliers for mini LED will be extremely useful, as it will help drive competition and lower the cost of components. It is suggested the die cost of a mini LED display would drop down from around $80 per unit to in the region of $45 per unit.
This reduced cost would in theory result in Apple using the technology more, with mini LED expected in between 30% and 40% of iPad shipments in 2021, and between 20% and 30% of MacBook shipments. Earlier estimates put the mini LED share at around 10 to 20% for each product range.
Future display technology
Apple is expected to employ two different types of display technology in the future, with it having invested in both mini LED and micro LED research and development. Of the two, mini LED will probably find more widespread use first, while micro LED may arrive in 2023 or 2024.
As the name suggests, mini LED consists of very small LEDs, smaller than typically used in current TFT backlight panels. As mini LEDs light up a smaller region of the display, the use of Mini LED will allow for selective dimming of the backlight itself.
By dimming areas of the backlight, the screen will be able to offer deeper black shades, as current TFT panels simply attempt to block out the backlight without turning it off to display a black pixel. With selective dimming of the backlight, darker shades could reach close to levels produced by OLED panels that don’t use a backlight at all, due to OLED’s use of self-illuminating pixels.
Micro LED takes the concept further, in producing even smaller LEDs the size of a display pixel. Rather than as a backlight, micro LED would be used to form the pixels on a display itself, and can potentially offer OLED-quality contrast.