# The get() method on dicts
# and its "default" argument
name_for_userid = {
382: "Alice",
590: "Bob",
951: "Dilbert",
}
def greeting(userid):
return "Hi %s!" % name_for_userid.get(userid, "there")
>>> greeting(382)
"Hi Alice!"
>>> greeting(333333)
"Hi there!"
>>> a = 1.6
>>> print(f'We have {a=} and {int(a)=}.')
>>> We have a=1.6 and int(a)=1.
>>> class show_time:
... def __init__(self, func):
... self.func = func
... def __call__(self, *args, **kwargs):
... start = time()
... result = self.func(*args, **kwargs)
... print(f'It took {time() - start:.4f}s')
... return result
...
>>> @show_time
... def test():
... return sum(n**2 for n in range(1000000))
...
>>> test()
It took 0.1054s
333332833333500000
>>> with open('test.txt') as f:
... print(f.read())
>>> It works!
>>> 1000000 # confusing
1000000
>>> 1e6 # not confusing but creates a float
1000000.0
>>> 1_000_000 # great!
1000000
>>> base = 20
>>> sum([1, 2, 3], base)
26
# How to sort a Python dict by value
# (== get a representation sorted by value)
>>> xs = {'a': 4, 'b': 3, 'c': 2, 'd': 1}
>>> sorted(xs.items(), key=lambda x: x[1])
[('d', 1), ('c', 2), ('b', 3), ('a', 4)]
# Or:
>>> import operator
>>> sorted(xs.items(), key=operator.itemgetter(1))
[('d', 1), ('c', 2), ('b', 3), ('a', 4)]
# Different ways to test multiple
# flags at once in Python
x, y, z = 0, 1, 0
if x == 1 or y == 1 or z == 1:
print('passed')
if 1 in (x, y, z):
print('passed')
# These only test for truthiness:
if x or y or z:
print('passed')
if any((x, y, z)):
print('passed')
Goat.Tech is First Gamified On-chain Reputation with Native Yield to earn $ETH ? and $GOAT ? and boost on-chain ReputationSocial Links: linktr.ee/goatxtechWebApp:goat.techChannel: @goatxtech?Transparency and security build trust, which is key at Goat.Tech.?Goat.Tech employs a comprehensive set of contract files and modules, each designed to uphold platform security and prevent unauthorized withdrawals or access to funds.✅All smart contracts are public and audited by top-tier Audit company Cantina/ Spearbit.?Learn more how your staked funds are completely protected at Goat.Tech: ?Shoutout to the GOAT Goat.Tech co-hosts with our partners to bring you multiple campaigns and earning opportunities.We're thrilled to introduce Lido $wstETH staking on Goat Dapp MainnetPoint tracking integration are now offering $wstETH stakers with greater benefits:?Build a high Web3 social standing in form of Trust Score?1.5x Goat.Tech Mainnet Points(will be convertible to disinflationary $GOAT token)?Earn great APR yields
The network of applications using blockchain technology built on Fantom Opera to bring community experiences and benefitsWebsite: aurafi.orgCEO: @chrisaurafiGood new!!! Farming works perfectly now!! No error in code but developer forgot to set the Farming contract to be the "AuraManager" which can mint $AURA.You can join Farming now!!!
Amazing ⭐️ HyperOS updates status for Poco F4 and Redmi K50iWe are here to provide news about each an every update about HyperOS Xiaomi HyperOS updates are closed for all Xiaomi devices ?Install HyperOS "AI Surprise Wallpapers" in your Xiaomi devices Install HyperOS "AI Surprise Wallpapers" in your Xiaomi devices Official Telegram Channel = @TECH_MUKUL
The Decentralized Money Transfer Protocol Revolutionizing Financial Interoperability. Incubated by @ChainGPT Announcements: t.me/KimaNetworkNews? HackaTRON Season 6 Twitter Space is LIVE TODAY! ?We're thrilled to announce that Kima is joining today's Twitter Space hosted by TRON DAO. ?As a proud Platinum Sponsor of HackaTRON Season 6, we're excited to dive into discussions on emerging blockchain technologies, the latest in the Bitcoin and crypto ecosystems, and share insights into the innovative solutions alongside esteemed projects:✅Chain GPT✅AI Tech✅GT-Protocol✅Router Protocol✅Moby Media⭐️ Highlight: Our CMO, Tomer Warschauer Nuni, will be speaking at the Bitcoin Halving celebration, showcasing how Kima is shaping the future of blockchain technology.
AmpereChain: The fastest D-QBFT blockchain with AMPERE crypto. Pioneering EVM public chain with privacy nodes. Unmatched speed, efficiency, privacy, and TPS. #DecentralizedTechDear Community,I have received lot of DM regarding vesting time of migration.Considering queries and objection we have decided to go with voting for merging decision1. Project is registered and they have shared formation, approval certificate2. There is one way(Either go with them or reject them). Once we opt for rejection we are completely out3. Our community must have to understand they are yet in presale and asking all tokens to release without reaching certain market cap will crash project. I had discussion with him for early release and he highlighted it. Many of you have intention to exit but none of project owner will allow such crash4. I asked same questions to seed funding users few days back and they opted to stay with them5. Dom and Moh already left project with no backing to support itI have clearly mentioned positive as well as negative side with our current situation.Requesting everyone to vote for next 3 days which will help us to go forward or return back to previous steps leaving them.
The right package for interview help to switch to Product Based Companies led by Tech Professionals. We provide OAs and interview experience, and post it at thejoboverflow.com, and notify in the TGVisit the Pinned messages for our Community Guidelines ?I don't know if there is a simpler way, but I know a way of changing profile picture. TJO profile picture is linked to gravatar. 1.So go to gravatar. Com 2.Sign in with email you registered tjo with3.change profile picture at gravatar. That's all!Thanks for showing such mad excitement! We've now got some exciting news to share. The first-ever Masterclass by AlgoUniversity is all set to take place. Join us in this Resume Crafting session by none other than Manas Sir himself!Yep, you heard it right! Manas Sir is ready for spilling all his insider secrets on how he nailed his resume that made him travel to not one, not two, but three different countries ✈️. It's an exclusive opportunity to learn from the best!