#voice-chat-text-0
1 messages Β· Page 583 of 1
Very coool!
you can stack conditions
!e py var = [a * 2 for a in [b * 3 for b in range(4)]] print(var)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
[0, 6, 12, 18]
tbh i learend list, set, dict and generator comprehension same time i learned if statements
@wraith mauve you probably want to use prebuilt, and tailor it on what you want
but its nice to learn how they works internally
ty β€οΈ
tuple?
tuple what
thats probably not a tuple comprehension, but a generator comprehension cast into tuple
!e py foo = (v for v in range(3)) print(foo) bar = tuple(v for v in range(3)) print(bar)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | <generator object <genexpr> at 0x7f26dd3b7d30>
002 | (0, 1, 2)
(x for x in obj) is a generator comprehension
the tuple part actualy cast the generator into tuple
?
!e ```py
foo = (v for v in range(3))
print(next(foo))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
0
!e
arr = list(x for x in range(5))
print(arr, type(arr))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
[0, 1, 2, 3, 4] <class 'list'>
Okay interesting
Yea
its usefull
Useful in ML
quantum computing...
Oh okay
and most GPU problably do that internally
Yea man never
its usefull on many data science
Meuvim is just what i call my neovim config lol
thats why im its herald
hello there people
Ey, not good, how about you?
Great, you are progressing at fast pace in python learning
i still call generator expression generator-comprehension i preffer consistency to match other comprehensions
hiii
building rich presence shouldnt be hard
lol
Its okay little panda
you just chat on #python-discussion
m new here so haha
idk what to do
so anyways how are u
how s life
how s coding
ehhhh
frustrating
Cheers guys, heading out π
u need to be positive guys like look at the bright side
omg why
I don't code bro i drink my matcha when claude code does it for me
it is nokia
hhahahahhaha i totally agree
but m feeling more dumb
with claude ai doing my work
claude's code sucks
@blissful hinge π
i have to rewrite the thing
not really
Ikr π
yes really
I've been learning side by side tho
Systems programming
u need just to know the good prompt to send
Nah
I've not been active enough
thats also false
You don't have to be sorry about that chill
π£οΈ just have convension
I've been entered just to hear what you are talking about
ok
Me?
im currently building our school project, what DB i could use?
preferably simple DB single file
I've just discovering in dicover tab because I'm still learning python so I want some incentivize
Supabase
do you know how can I know how many time i've been active
sorry im having hard time catching up ._.
You can't you just have to stay active
you can participate on conversation at #python-discussion
salutations
#bot-commands
@empty grail π
mine still sucks
How are you guys?
Sorry, I can't turn on my mic.
it's the first channel in voice
also enable krisp
@nimble scarab π
the what?
ayo ech ehc ehc ehc ech ech lol
we have hard conversation about politics and tech here
@pliant warren π
Hello
!voice
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
I'm sorry I can't talk to you because I don't speak English.
Its okay
Is it a library? splite Open source
@young matrix are u talking about detecting fraud without knowing previous data
I'm learning in Two pi channel it's arabic tho
sami it is
@undone kindle π
hi
I'm disconnecting from that voice chat my PC is veeeery hot
my audio sucks....
@somber heath i dont think that would give satisfying resolution
i mean precision
I'm not active enough.
go to #python-discussion
and engage with the discussion there
Hey @sleek otter
do you schcleud the voice chat or what?
Hi @pastel hearth
Hi
how's it going? I'm reading on namedtuples in the python docs π
Ooo nice
!e
from collections import namedtuple
# Define a Book namedtuple
Book = namedtuple('Book', ['title', 'author', 'year', 'price'])
# Create instances
books = [
Book("1984", "George Orwell", 1949, 9.99),
Book("The Great Gatsby", "F. Scott Fitzgerald", 1925, 12.99),
Book("To Kill a Mockingbird", "Harper Lee", 1960, 10.99),
]
# 1. Access by attribute (readable)
for book in books:
print(f"{book.title} by {book.author} ({book.year}) - ${book.price}")
print()
# 2. Unpacking
title, author, year, price = books[0]
print(f"Unpacked: {title} costs ${price}")
print()
# 3. Immutable (can't modify)
try:
books[0].price = 5.99
except AttributeError as e:
print(f"Error: {e}")
print()
# 4. Works like a dict
print(books[0]._asdict())
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 1984 by George Orwell (1949) - $9.99
002 | The Great Gatsby by F. Scott Fitzgerald (1925) - $12.99
003 | To Kill a Mockingbird by Harper Lee (1960) - $10.99
004 |
005 | Unpacked: 1984 costs $9.99
006 |
007 | Error: can't set attribute
008 |
009 | {'title': '1984', 'author': 'George Orwell', 'year': 1949, 'price': 9.99}
Thatβs nice then π
@misty walrus
https://docs.python.org/3/tutorial/datastructures.html @misty walrus
hello
Greetingsgs
!e
# Real-world: Social network - find common friends
user1_friends = {'Alice', 'Bob', 'Charlie', 'Diana', 'Eve'}
user2_friends = {'Bob', 'Charlie', 'Frank', 'Grace', 'Henry'}
print("User 1 friends:", user1_friends)
print("User 2 friends:", user2_friends)
print()
# 1. Find common friends (intersection &)
common = user1_friends & user2_friends
print(f"Friends in common: {common}")
print()
# 2. Find all friends of either user (union |)
all_friends = user1_friends | user2_friends
print(f"All unique friends: {all_friends}")
print()
# 3. Find friends only user1 has (difference -)
only_user1 = user1_friends - user2_friends
print(f"Only user1's friends: {only_user1}")
print()
# 4. Fast membership testing
print(f"Is Bob a mutual friend? {'Bob' in common}")
print()
# 5. Remove duplicates from a list
emails = ['alice@mail.com', 'bob@mail.com', 'alice@mail.com', 'charlie@mail.com', 'bob@mail.com']
unique_emails = set(emails)
print(f"Unique emails ({len(unique_emails)}): {unique_emails}")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | User 1 friends: {'Bob', 'Diana', 'Eve', 'Charlie', 'Alice'}
002 | User 2 friends: {'Bob', 'Grace', 'Charlie', 'Henry', 'Frank'}
003 |
004 | Friends in common: {'Charlie', 'Bob'}
005 |
006 | All unique friends: {'Bob', 'Henry', 'Charlie', 'Frank', 'Alice', 'Grace', 'Eve', 'Diana'}
007 |
008 | Only user1's friends: {'Eve', 'Alice', 'Diana'}
009 |
010 | Is Bob a mutual friend? True
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/4SHGDZ22Q4T5XS5HRPV34RCNSY
!e
# Real-world: Pizza party - different toppings each person likes
alice_toppings = {'pepperoni', 'mushrooms', 'onions', 'sausage', 'peppers'}
bob_toppings = {'pepperoni', 'olives', 'mushrooms', 'garlic', 'basil'}
print("=" * 50)
print("π PIZZA PARTY TOPPINGS π")
print("=" * 50)
print(f"Alice wants: {alice_toppings}")
print(f"Bob wants: {bob_toppings}")
print()
# 1. Union (|) - Make a pizza with all toppings either wants
all_toppings = alice_toppings | bob_toppings
print(f"β
UNION (everything either wants):")
print(f" {all_toppings}")
print(f" Total unique toppings: {len(all_toppings)}")
print()
# 2. Intersection (&) - Toppings both agree on
both_love = alice_toppings & bob_toppings
print(f"β€οΈ INTERSECTION (both love these):")
print(f" {both_love}")
print()
# 3. Difference (-) - What Alice wants but Bob doesn't
alice_only = alice_toppings - bob_toppings
print(f"π― DIFFERENCE (Alice wants, Bob doesn't):")
print(f" {alice_only}")
print()
# 4. Symmetric difference (^) - Toppings only ONE person wants
compromise = alice_toppings ^ bob_toppings
print(f"βοΈ SYMMETRIC DIFFERENCE (only one person wants):")
print(f" {compromise}")
print()
# 5. Membership testing (in)
print(f"π MEMBERSHIP TESTING:")
print(f" Is 'pepperoni' on both lists? {'pepperoni' in both_love}")
print(f" Does Alice want 'garlic'? {'garlic' in alice_toppings}")
print(f" Does Bob want 'sausage'? {'sausage' in bob_toppings}")
print()
# 6. Remove duplicates (create set from list)
all_votes = ['pepperoni', 'mushrooms', 'pepperoni', 'olives', 'mushrooms', 'pepperoni']
popular = set(all_votes)
print(f"π REMOVE DUPLICATES (vote counts):")
print(f" Raw votes: {all_votes}")
print(f" Unique votes: {popular}")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | ==================================================
002 | π PIZZA PARTY TOPPINGS π
003 | ==================================================
004 | Alice wants: {'peppers', 'pepperoni', 'mushrooms', 'sausage', 'onions'}
005 | Bob wants: {'pepperoni', 'mushrooms', 'olives', 'basil', 'garlic'}
006 |
007 | β
UNION (everything either wants):
008 | {'peppers', 'pepperoni', 'mushrooms', 'onions', 'basil', 'olives', 'sausage', 'garlic'}
009 | Total unique toppings: 8
010 |
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/EE7ISOQQGWSZWGWQP5UNSLTYBE
Hello @cerulean roost
Wyd
Also btw what is uniyo, I see its in your bio
Nice
Its a good website
What is it for
As in the Company
Im on android personaly
What are the services for
I do Still have my iphone
It dosnt look like that on pc
Nothing
Just typed the url
On desktop its perfect
Is it UNIYO LTD
Hello π
I know a little bit of HTML and css
Need to improve on this
Basicly you have a cousin or something over
K think thats not exactly a good way of putting that lol
I have a basic nav
I dont update it oftern
The site
This was my last commit
Im doing some homework rn for food tech
Need to pass my gcse's somehow
1 year
Python i heard is quite good in back end
!e
# Drama: rival bands comparing their setlists
band_a = {'rock', 'metal', 'blues', 'jazz'}
band_b = {'metal', 'pop', 'electronic', 'jazz'}
print(":guitar: BATTLE OF THE BANDS :guitar:\n")
print(f"Band A: {band_a}")
print(f"Band B: {band_b}\n")
# Union - merge all genres
print(f":radio: MEGA FESTIVAL (all genres): {band_a | band_b}\n")
# Intersection - common ground
print(f":handshake: THEY AGREE ON: {band_a & band_b}\n")
# Difference - unique flex
print(f":muscle: Band A's ONLY genres: {band_a - band_b}")
print(f":muscle: Band B's ONLY genres: {band_b - band_a}\n")
# Symmetric difference - the drama
drama = band_a ^ band_b
print(f":zap: THE BEEF (genres only one has): {drama}\n")
# Membership test
print(f":fire: Does Band A do metal? {('metal' in band_a)}")
print(f":fire: Does Band A do pop? {('pop' in band_a)}")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | :guitar: BATTLE OF THE BANDS :guitar:
002 |
003 | Band A: {'rock', 'blues', 'jazz', 'metal'}
004 | Band B: {'electronic', 'jazz', 'metal', 'pop'}
005 |
006 | :radio: MEGA FESTIVAL (all genres): {'blues', 'electronic', 'pop', 'jazz', 'rock', 'metal'}
007 |
008 | :handshake: THEY AGREE ON: {'jazz', 'metal'}
009 |
010 | :muscle: Band A's ONLY genres: {'rock', 'blues'}
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/WTEYCMGEURMVVMGV3JHBKUUB6U
@mortal burrow
It's interesting.
To eliminate Redundancy of elements.
Vein diagram
Circle mostly
Yeah
How would you do something like this? https://en.wikipedia.org/wiki/Euclidean_algorithm
In mathematics, the Euclidean algorithm, or Euclid's algorithm, is an efficient method for computing the greatest common divisor (GCD) of two integers, the largest number that divides them both without a remainder. It is named after the ancient Greek mathematician Euclid, who first described it in his Elements (c.β300 BC).
It is an example of ...
Venn diagram
@rough tapir
Yes
Yeah. Venn diagram.
time complexity of set is faster than Lists
Wym
Also to check if duplicates are there.
Set()
What are you asking with this?
You mean set() is quicker than list []
In some cases.
A friend said when i finished a simple calculator to do this
What theme ?
I will hop off now due to it being 11PM and i have school tmr
Bye ppl
Gn
Also good luck with uniyo @cerulean roost hope it goes well
Emojis
WE love r/unixporn
No its not nsfw
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | RELATIONSHIP COMPATIBILITY TEST
002 |
003 | Nerd likes: {'coffee', 'gaming', 'anime', 'memes', 'coding'}
004 | GF likes: {'coffee', 'shopping', 'anime', 'cooking', 'memes'}
005 |
006 | [OK] WE AGREE ON: {'coffee', 'memes', 'anime'}
007 | (phew, at least 3 things!)
008 |
009 | [HIS] HE WON'T STOP TALKING ABOUT: {'gaming', 'coding'}
010 |
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/2MDNXP2ZBFHODJ7SRMOFF35PXI
Similarities
Yeah.
They need data to feed the algorithm.
i think it helps in filtering the data
@oak silo
Yeah.
gromov wasserstein alignment
The main difference is with list you need to go one by one searching
in sets it uses hash table for mapping
i think
XD
Lol
@spark oriole Hellow π
!e
# What makes you different from your crush
you = {'gaming', 'coding', 'anime', 'coffee'}
crush = {'coffee', 'gym', 'cooking', 'anime'}
unique = you ^ crush
print(f"You: {you}")
print(f"Crush: {crush}")
print(f"Why you're incompatible: {unique}")```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | You: {'anime', 'coffee', 'gaming', 'coding'}
002 | Crush: {'anime', 'coffee', 'gym', 'cooking'}
003 | Why you're incompatible: {'coding', 'gym', 'gaming', 'cooking'}
@woeful void π
Hello
i made a cool program in commodore 64 6502 assembly that basically does the same thing as cat /dev/urandom on linux
i still havent figured out how to remove the static from OBS
i initialize the SID chip and then grab the number the SID generates every iteration of the loop and store that number in the accumulator, then jump to the chrout subroutine to print a character on the screen with that value
the SID is great at making pseudo random numbers
a quirk about the c64 you may find entertaining is that normally, the kernel does not know what to do with an assembled program, you cant just do the RUN command on it and have it RUN since the RUN command only works on BASIC scripts, you have to either manually run the SYS command and enter the memory location as a parameter, or the programmer has to inject the BASIC script that basically points to the assembled binary's memory location.
you have to inject it as raw bytes and start the program counter at the memory location BASIC code starts at for this trick to work
assemblers make this easy though
but if you were writing this file in a monitor, you would have to calculate what the first 2 bytes would be because the first two bytes is a pointer to the next line
thank god for assembler abstractions
or in this case, thank DEC
since they laid the groundwork for these abstractions
oh yeah and BASIC commands are stored as tokens, i turned the sys token into a constant so i could make it more readable
sys token = $9e
and i made a constant null = $00
@somber heath what do you think of this when you have a moment
I think that you've written a lot of words and I currently have the approximate cognitive fortitude of a peanut.
what i wrote may make more sense if you look at the turbo macro pro syntax page
https://turbo.style64.org/docs/turbo-macro-pro-tmpx-syntax
since this is the assembler im using
@vagrant pumice oh yeah ive been doing ruby
Hey
!e
for(let t=0;;t++)console.clear(),console.log(
[...Array(28)].map((_,y)=>
[...Array(80)].map((_,x)=>
" .:=+*#%@"[
(((x^y+t)&((x*t>>3)|(y+t)))^(x*y+t)%13)%9
]
).join('')
).join('\n')
),await new Promise(r=>setTimeout(r,40))
:x: Your 3.14 eval job has completed with return code 1.
001 | File [35m"/home/main.py"[0m, line [35m1[0m
002 | for([1;31mlet t[0m=0;;t++)console.clear(),console.log(
003 | [1;31m^^^^^[0m
004 | [1;35mSyntaxError[0m: [35minvalid syntax. Perhaps you forgot a comma?[0m
did not notice its typescript
!e
while 1:print('\n'.join(''.join(" .:=+*#%@"[((x^y+t)&((x*t>>2)|(y+t))^x*y)%9]for x in range(80))for y in range(25)));t=-~globals().get('t',0);__import__('time').sleep(.05);print('\033[H')
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m1[0m, in [35m<module>[0m
003 | while 1:print([31m'\n'.join[0m[1;31m(''.join(" .:=+*#%@"[((x^y+t)&((x*t>>2)|(y+t))^x*y)%9]for x in range(80))for y in range(25))[0m);t=-~globals().get('t',0);__import__('time').sleep(.05);print('\033[H')
004 | [31m~~~~~~~~~[0m[1;31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[0m
005 | File [35m"/home/main.py"[0m, line [35m1[0m, in [35m<genexpr>[0m
006 | while 1:print('\n'.join([31m''.join[0m[1;31m(" .:=+*#%@"[((x^y+t)&((x*t>>2)|(y+t))^x*y)%9]for x in range(80))[0mfor y in range(25)));t=-~globals().get('t',0);__import__('time').sleep(.05);print('\033[H')
007 | [31m~~~~~~~[0m[1;31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[0m
008 | File [35m"/home/main.py"[0m, line [35m1[0m, in [35m<genexpr>[0m
009 | while 1
... (truncated - too long, too many lines)
Full output: https://paste.pythondiscord.com/NRQ74UWAV2FEC754272VJWCAQE
flip
@timber arrow π
hold on
my voice chat i need to verify
oh i havent been in this server for 3 days
i need to to be able to talk
hmm?
im not sure i havent joined before from what remember
what projects are u working on currently?
ahaha all good
uhm currently im working on a like utility and music playrer
mmm let ssee if i can upload images
so u can see
you have probably seen something like it but i did my own spin on it
yeah its based on another tool let me find that for u
lmao similar but for my own purposes
and the music player
i think so
lmao
but its going good actually
what have u made in the past?
oh yeah ive made a discord bot before
oop
fair enough\
haha same
my bad
how many lines is ur image algorithim thingy
oh lmaoo
no problem
thats cool
nice and debloated
fair enough honestly
i first learned batch when i started coding
i think its very easy i learned how to make a multitool in 5 mins
from 0 prior knowlege
and ahk is cool aswell
for like macroing and mouse movements automation
thats cool
im thinking of learning like C#
or anything C
idk its really good for a lot of things but its a bit complex
yeaaa
yeah
assembly π
understandable
are u on linux or windows currently?
what distro
mmm
yeahh
mm yeah i like arch and cachy currently
yeah honestly
honestly just pull a terry davis make ur own haha
me neither
yeah
eventually
TRASH os's essentially
augh it would be so cancer
haha
ofcourse i would
and ofcourse i would update my mainstream windows os to upgrade their spyware YAYYYYY
some of that is good tho
theres many bad places on the internet that shouldnt be shown
yep
giving ur adress
honestly there will always be a kid who makes their own shit i think people need to start their homelabs way earlier than expected
@silver ermine π
haha
yea
i mean same with mainstream browsers
or some
yeah
thats why i made my music player i dont want to rely on stupid big companys
haha
no need for subscriptions when piracy exists
yeah
i joke with my friends sometimes on like "oh u need a subscription to be able to buy this subscription" but i think its closer than we think
yea
haha
like imagen someone random goes in your house and looks through ur drawers but ANYONE by law is allowed to
its completely stupid
lol
yeaa ur not wrong
yea
its going to be a subscription based "utopia" with no free will
if we dont
we are so screwed
yea
jesus
tragic
"nah mate u cant do that"
so corrupted
dear god
lordy
yeah
i wouldnt put it past them
yea
well coding jobs now are people reviewing ai code
its so heartbreaking
haha
yeah
yeah in games it shows and even in os's such as windows 12 taking forever is because they use AI
Hello
hi
so indie games will be less and less over time
they dont do shit in over here in south africa luckily
while we ask for childrens face to verify theyre a child
Afrikaans
and there isnt a database of childrens faces from that app
ya
exactly
we pwomise brah
"so we can improve user expierience based on ur data"
"we arent anylizing it brah we promise"
ya
for real
like where is our vote here
yep discord will do it soon
face age verification
if they do im switching to some other shit
YAYYYY
yeah
augh its disgusting homelabs on top
yep wouldnt put it past them
same here
insane prediction
id say maybe 10 years ago i thought there would be subscription based os's
but it turns out windows 12 will be subscription based
yeah
Lordy it will be like phone storage
pay 70 dollars per month to get more phone storage
then it would be differant
fair enough honestly
@glossy hollow π
hlooo
it has all the hardware but it isnt enabled because of big company
yep
people leave it too late
exactly
i mean god i thought on windows 7 that having to pay to use the os was mad
or paying to use certian features
yup , people are busy in their life's and as soon as something big happens
i think a person should be taught in schools that they should save some time and discuss some topics like these in a week
pay for ur os to be bare minimum
honestly
because then the kids will be GAY and thats sooo baddd
lmao
mhm
@timber arrow yup
its always funny when some like furry or something hacks some important goverment info
exactly
I have also heard a news that most of the companies are moving towards subscription model instead of letting people own anything which they are paying off
crazy shiut
yea
u wanna know something crazy opal
im not even using discord currently im using my own app that uses a discord token to speak
i dont even have discord installed
haha
i know
yea thats exactly it
they dont know im spoofing the app
ty
yeah this is an alt
lmao
yaaa i dont say this stuff on my main
a engineer will not be a engineer if he doesn,t break rules and goes out of the box
haha
fair enough
is also more incriminating to delete it
yeah its alright
same
but opal don't u think every country is trying to isolate nowadays
making their own currencies , reserving gold
it will affect the businesess bcz its unfair for an mnc
exactly
like in china u cannot use youtube , twitter....
u cant use discord in pakistan and russia
i think
and the us kidnapping the greenland presidient or wtvr
yup bcz govt tryna make a bubble in their own countries and not let people connect with the world
North Korea is final boss in these kind of people manipulationπ
i shall be on my way interesting chat here see you people
hlo
@heady pilot π
read it chaiwala
ok
I have not been active enought here
i found my clown twin
so funny
haha π
thanks for the compliment
whassup my indian brother
!e
# Find skills you need to learn to impress your crush
your_skills = {'python', 'javascript', 'html', 'gaming'}
crush_skills = {'python', 'sql', 'react', 'cooking'}
# What you're missing (set comprehension + symmetric diff)
missing = {skill for skill in (your_skills ^ crush_skills) if skill not in your_skills}
print(f"Your skills: {your_skills}")
print(f"Crush skills: {crush_skills}")
print(f"YOU NEED TO LEARN: {missing}")```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | Your skills: {'gaming', 'python', 'javascript', 'html'}
002 | Crush skills: {'sql', 'cooking', 'python', 'react'}
003 | YOU NEED TO LEARN: {'cooking', 'react', 'sql'}
hi
thanks still I've not been active enough
are you from india?
ok
I'm from morocco
I like morocco π
Not a lot I know Just the basics but with some about OOP programing in python
Great!
@zealous bobcat π
π
#voice-verification @wary pasture
I'll retry
Yep, try after few days
Hello
!beginner
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff β an online book (also available to purchase as a physical book)
- Harvardβs CS50P course β video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course β text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
@wary pasture
what's the red file
Hii
hello
Ive been messageing alot still verifying vc isnt working
maybe #voice-verification
My wi-fi is very bad
Hi
I'm out i'll be back soon
Hello π
!e
questions = ['name', 'quest', 'favorite color']
answers = ['lancelot', 'the holy grail', 'blue']
for q, a in zip(questions, answers):
print('What is your {0}? It is {1}.'.format(q, a))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | What is your name? It is lancelot.
002 | What is your quest? It is the holy grail.
003 | What is your favorite color? It is blue.
!e py print(*zip(range(3), range(999)), sep=", ")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
(0, 0), (1, 1), (2, 2)
!e py print(*zip(range(6), range(999)), sep=", ")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)
!d itertools.zip_longest
itertools.zip_longest(*iterables, fillvalue=None)```
Make an iterator that aggregates elements from each of the *iterables*.
If the iterables are of uneven length, missing values are filled-in with *fillvalue*. If not specified, *fillvalue* defaults to `None`.
Iteration continues until the longest iterable is exhausted...
!e py import itertools for a, b in itertools.zip_longest(range(3), range(8)): print(a, b)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 0 0
002 | 1 1
003 | 2 2
004 | None 3
005 | None 4
006 | None 5
007 | None 6
008 | None 7
!e py import itertools for a, b in itertools.zip_longest(range(8), range(3)): print(a, b)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 0 0
002 | 1 1
003 | 2 2
004 | 3 None
005 | 4 None
006 | 5 None
007 | 6 None
008 | 7 None
!e py import itertools for a, b in itertools.zip_longest(range(8), range(3), fillvalue="+++"): print(a, b)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 0 0
002 | 1 1
003 | 2 2
004 | 3 +++
005 | 4 +++
006 | 5 +++
007 | 6 +++
008 | 7 +++
!e py values = {1, 2, 3} for _ in values: values.add(4)
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m2[0m, in [35m<module>[0m
003 | for _ in [1;31mvalues[0m:
004 | [1;31m^^^^^^[0m
005 | [1;35mRuntimeError[0m: [35mSet changed size during iteration[0m
!e
import math
raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]
filtered_data = []
for value in raw_data:
if not math.isnan(value):
filtered_data.append(value)
print(filtered_data)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
[56.2, 51.7, 55.3, 52.5, 47.8]
nan = float("NaN")
values = [1, 2, nan, 3, 4]```
[v for v in raw_data if v != nan]```
@cerulean roost At which part you are?
https://docs.python.org/3/tutorial/datastructures.html @candid spire
import math
...
filtered = [v for v in raw_data if not math.isnan(v)]```
!d math.isnan
math.isnan(x)```
Return `True` if *x* is a NaN (not a number), and `False` otherwise.
@proud badge π
@cerulean roost I think c++ and c are preferred for game dev
and c#
c python is implementing a c module in python
But we are using python
cpython is a implementation of python
This is cpython
what you learning right now
you can make library on c and use it on python
That's what I said!
JVM is exclusive to Java?
@little scarab jvm on python?
@candid spire
i love python for the 2 operation stacking
i mean comparison stacking
A < X < B is super intuitive
theres no order
theres no order
I think in other languages we are forced to use and, or, not?
python do (A < X) < B and the < operator return the X no??
or the operation was parsed into
(A < X) and (X < B)
Comparisons can be chained. For example, py a < b == c tests whether a is less than b and moreover b equals c.
With () it treats them as whole?
i think this is how the python does it
True and true = true
a < x < b = true
on the python-bytecode it parse it to be like that
Yeah classic abstraction of python
this should be (a < x) and (x < b) and (b == true) if python does that then
!e
a, b, c = 3, 5, 5
# Chained β both comparisons checked together
print(a < b == c) # True (a < b AND b == c)
# Parens force (a < b) first β True, then compares True == 5
print((a < b) == c) # False (True != 5)
# Parens force (b == c) first β True, then compares 3 < True
# Sneaky: True is 1 in Python, so this is 3 < 1
print(a < (b == c)) # False```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | True
002 | False
003 | False
Ai generated?
:white_check_mark: Your 3.14 eval job has completed with return code 0.
5
well bc its a special operation
It can be infinite?
maybe
Is there a way to check this?
!e
a = bool(-10) # True
b = bool(float('inf')) # True
c = bool(float('-inf')) # True
print(a)
print (b)
print (c)
A and not B or C is equivalent to (A and (not B)) or C. As always, parentheses can be used to express the desired composition.
!e
a = bool(-10) # True
b = bool(float('inf')) # True
c = bool(float('-inf')) # True
print(a)
print (b)
print (c)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | True
002 | True
003 | True
parenthesis just folds the expression
@paper wolf yes any non zero number is truthy
maybe bc.... on the actual data negative is still a value
from quimb.tensor.tn1d.compress import tensor_network_1d_compress # type: ignore
from qrisp_aqc.mps_encoding.sequentual import _generate_unitary_layer # type: ignore
import copy
num_qubits = 10
num_layers = 4
max_bond = 4
mps = qtn.MPS_rand_state(num_qubits, bond_dim=max_bond, seed=0)
mps = tensor_network_1d_compress(mps, max_bond=max_bond)
mps_copy: qtn.MatrixProductState = copy.deepcopy(mps)
unitary_layers = []
# Preprocessing
mps_copy.normalize()
mps_copy.compress(form="right")
mps_copy.permute_arrays("lpr")
mps_copy.right_canonize(normalize=True)
# The main loop where we generate the unitary layers and apply them to the MPS
for _ in range(num_layers):
# Truncate bond dimension to 2
mps_truncated = copy.deepcopy(mps_copy)
mps_truncated.compress(form="right", max_bond=2)
mps_truncated.right_canonize(normalize=True)
# Generate the unitary layer from the truncated MPS
# unitary_layer definition is a bit long so I omitted
# it here, but main thing is it does not modify the MPS
# (it only looks at the tensors to generate the unitaries)
unitary_layer = _generate_unitary_layer(mps_truncated)
unitary_layers.append(unitary_layer)
# Apply the inverse of the layer to the MPS
# (equivalent to disentangling it towards the zero product state)
for qubits, unitary in reversed(unitary_layer):
if len(qubits) == 1:
mps_copy.gate_(unitary.conj().T, where=qubits, contract=True)
else:
mps_copy.gate_split_(unitary.conj().T, where=qubits)
# mps_copy.gate_nonlocal_(unitary.conj().T, where=qubits)
print(fidelity_with_zero_state(mps_copy))
wdym?
on the two's compliment, negative means the most significant bit is 0
positive means the most significant bit is 1
Quantum guy @cerulean roost
Everything goes over my head
i have no idea what those function does lol
on twos compliment
the most significant bit tells if its a positive
like 0b1000 means +0
how do I verify to speak in voice?
0b1001 means 1
Kai Nakamura is 10x python dev??
whos said that
no way
he's projecting
:=
:==== (bigger, better)
thats syntax error
machine can't handle it
lol
sounds like a machine problem you keep doing your thing and let the compiler people catch-up
!e (a := 3, print(a))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
3
!e (a:==== 3, print(a))
:x: Your 3.14 eval job has completed with return code 1.
001 | File [35m"/home/main.py"[0m, line [35m1[0m
002 | (a:=[1;31m==[0m= 3, print(a))
003 | [1;31m^^[0m
004 | [1;35mSyntaxError[0m: [35minvalid syntax[0m
!e (a = 3, print(a))
:x: Your 3.14 eval job has completed with return code 1.
001 | File [35m"/home/main.py"[0m, line [35m1[0m
002 | ([1;31ma = 3[0m, print(a))
003 | [1;31m^^^^^[0m
004 | [1;35mSyntaxError[0m: [35minvalid syntax. Maybe you meant '==' or ':=' instead of '='?[0m
okay bigger not always better!
you cant asign variable inside a expression
!e (a := 3, print(a))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
3
@cerulean roost Contact hemlock, maybe he can grant you perms
Yeah but he is only mod which accepts the friend request and respond to DM
crhis >>
look at the >>>
@cerulean roost you'll get video perms only when theres mods supervising
else, no vid perms
when mods joined
mostly hemlock and chris
but not this time
they're probably doing some w*rk
@inner hill How's Going
Going good
#voice-verification @torn spire
@inner hill yes
how to get voice verify role
Calm down π€£ @frail sorrel
!e
x = '' or 'Trondheim'
# Non-boolean use: we see the actual returned value
print(x) # Trondheim (a string, not True!)
# Boolean use: same expression, but only its truthiness matters
if '' or 'Trondheim':
print("truthy") # runs, because 'Trondheim' is truthy```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | Trondheim
002 | truthy
@cinder vale @sweet plume
@raw obsidian
@dry jasper π
whiplash?
!e
def C():
print("C was evaluated!")
return True
A = True
B = False
# B is False, so Python stops there. C() never runs.
result = A and B and C()
print(result)```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
False
By this script I believe python looks at string1 = '' as empty and not false
string1 = ''
if string1:
print("This is true")
else:
print("This is false")
!e string1 = ''
if string1:
print("This is true")
else:
print("This is false")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
This is false
if string1:
print("This is true")
else:
print("This is false")
You understand this part of the Python docs ?
no
tbh i didn't understand it let me search for it
No worries letβs do it !
aw but i'm just a beginner in coding using python but why not let's do it
no worries man we're here to help each other any doubts or questions feel free to ask !
@cerulean roost https://i3wm.org/
i3 is a tiling window manager with clean, readable and documented code, featuring extended Xinerama support, usage of libxcb instead of xlib and several improvements over wmii
Any idea about rebase in git?
@cerulean roost
@upbeat oasis
@candid spire @upbeat oasis
Are you making your day positive ( self - deterimination ) @midnight agate
is that a set operation sir
5.6
@midnight agate
@midnight agate
ambiguity
Zellij @midnight agate
building from the ground up has many benefits
@upbeat oasis
!e
Κ€,Κ£=1.79175946923,1.94591014906;print(str(round(2.718281828 ** Κ€))+str(round(2.718281828 ** Κ£)))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
67
Hi @lunar crypt
Hi @cerulean roost
@candid spire
@amber willow π
Salut
@dense sail π
iβm not eligible yet π
No one particular thing.
On a scale of one to this, how bad is winter where you are, @somber heath ?
This is normal where I am
although this year we had all this in 24 hours, which is unusual
It looks cool for somebody who haven't seen snow before ,
It might pretty terrible for people to live in such conditions
Scituate, Massachusetts be like
What is it?5D Chess With Multiverse Time Travel the first ever chess variant with spatial, temporal, and parallel dimensions. It's the first ever chess variant with multiverse time travel!
Features
- Sharpen your tactics by solving a collection of multiverse chess puzzles.
- Practice against four different AI personalities, each with different streβ¦
$11.99
7977
@hardy glade π
Hi opal
@warm bluff π
Write web apps in 80% fewer tokens. A programming language designed for maximum efficiency.
a... it looks AI generated
variables on MD???
ello opal
π£οΈ "back in the days"
@lapis aurora π
dead headset
@paper wolf this is ai
@fierce veldt π
here
Hi
@sacred path π
hi
https://docs.python.org/3/tutorial/datastructures.html @sacred path 5.7
thanks
while, for, if elif, else
English
... == placeholders
compound expression (5 + 3) * 2
A compound expression is formed by combining multiple sub-expressions using operators (like +, -, or and). It still results in a single final value
Compound Statements
Examples: if, for, while, try, and def.
A compound statement contains and controls other statements
what would be examples of the statements a compound statement controls?
if balance > 0:
# These statements are controlled by the if-statement
print("Account is active.")
deduct_fee()
balance = balance - 5.00
A compound statement (or block) groups multiple individual instructions so they execute together as a single unit under a specific control flow
dunder methods:
The Boolean operator "not" is able to invert the Boolean value of an object.
Hello π
x = 10 + 20
Expression: 10 + 20 (Code that must be calculated).
Result: It evaluates to the value 30.
Object: A memory slot is allocated to hold the integer 30, and x points to it.
An actual instance of data stored in memory.
An object is one value.
An expression is code that produces one value.
These have (Boolean value?) lower priorities than comparison operators; between them, not has the highest priority and or the lowest, so that A and not B or C is equivalent to (A and (not B)) or C
"When in doubt, print it out" - OpalMist
These have (and and or operators) lower priorities than comparison operators; between them, not has the highest priority and or the lowest, so that A and not B or C is equivalent to (A and (not B)) or C
!=
Arithmetic operation are numeral operation in this case
Boolean operators like and, or, and not are evaluated after comparison operators like ==, <, >, >=, etc.
But among the Boolean operators themselves, Python evaluates not first, then and, then or.
print(1 + 2 * 3)```
Hi @slender sierra welcome! feel free to ask any questions
!e
print(1 + 2 * 3)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
7
*, @, /, //, %
Multiplication, matrix multiplication, division, floor division, remainder [6]
+, -
Addition and subtraction
!e
print((1 + 2) * 3)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
9
HiβΊοΈ Thanksπ»
print(1+(3*2)/2%2)
!e
print(1+(3*2)/2%2)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
2.0
AI BOOM BOOM easy @cerulean roost
wdym?
!e
for A in [True, False]:
for B in [True, False]:
for C in [True, False]:
print(A, B, C, "->", not A and not B or C)```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | True True True -> True
002 | True True False -> False
003 | True False True -> True
004 | True False False -> False
005 | False True True -> True
006 | False True False -> False
007 | False False True -> True
008 | False False False -> True
CODE
data structure and algorithm
Hi @latent jay welcome, we're reading here:
It is making all combination and checking the boolean condition at the last.
A is false, B is False, and C is True. in First Case.
It looks like a truth table
!e py import itertools for a, b, c in itertools.product([True, False], repeat=3): result = not a and not b or c print(f"not {a} and not {b} or {c} ->", result)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | not True and not True or True -> True
002 | not True and not True or False -> False
003 | not True and not False or True -> True
004 | not True and not False or False -> False
005 | not False and not True or True -> True
006 | not False and not True or False -> False
007 | not False and not False or True -> True
008 | not False and not False or False -> True
If both of the conditions are True the result will return True. But if one condition is False it will return False
Readble to human eyes now.
!e
a,b,c = True, True, True
print(a and (b and c))
Mental note - slow is fast
:x: Your 3.14 eval job has completed with return code 1.
001 | File [35m"/home/main.py"[0m, line [35m1[0m
002 | if a and[1;31m[0m
003 | [1;31m^[0m
004 | [1;35mSyntaxError[0m: [35minvalid syntax[0m
!e
a,b,c = True, True, False
print(a and (b and c))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
False
!e py a = b = c = True print(a, b, c)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True True True
!e py a, b, c = True, False, True print(a, b, c)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True False True
True and True = Always True
Everything Else false.
True or False = True
False or True = True
remaining False
If Maths is correct.
!e
a,b,c = True, True, False
print(a or (b and c))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
!e
a,b,c = True, True, False
print((b and c) or a)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
If there's a False/True on 'or' it will always return True.
This is what goes on
left to right
for "or"
it stops the moment it find true
for "and"
it stops the moment it find false
!e
a,b,c = True, True, False
print( b or a and c)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
I believe python focuses more on the Boolean Operator than the Evaluation.
!e
a,b,c =True, True, False
print( b and a and c)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
False
Imagine a huge Boolean Expression to solve it might take time evalutaing each one of them. It is just quick to just short circuit.
!e a,b,c =True, True, False
print( b or a or c)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
!e
a,b,c =True, True, False
print( b or a or c) ```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
!e ```py
class Foo:
def bool(self):
raise Exception("I was booled.")
foo = Foo()
if True or foo:
print("Hello, world.")```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
Hello, world.
!e ```py
class Foo:
def bool(self):
raise Exception("I was booled.")
foo = Foo()
if False or foo:
print("Hello, world.")```
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m7[0m, in [35m<module>[0m
003 | if False or [1;31mfoo[0m:
004 | [1;31m^^^[0m
005 | File [35m"/home/main.py"[0m, line [35m3[0m, in [35m__bool__[0m
006 | raise Exception("I was booled.")
007 | [1;35mException[0m: [35mI was booled.[0m
!e
x = 5
if x > 10 and x / 0 > 1:
print("Hello")
:warning: Your 3.14 eval job has completed with return code 0.
[No output]
!e ```py
class Foo:
def bool(self):
raise Exception("I was booled.")
foo = Foo()
print(False or foo)```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
<__main__.Foo object at 0x7f922ec286e0>
Hi @rocky island welcome
!e ```py
class Foo:
def bool(self):
raise Exception("I was booled.")
foo = Foo()
print(True or foo)```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
!e
x = 11
if x > 10 and x / 0 > 1:
print("Hello")```
Hi @rare yew welcome!
hi
hi thank you i'm just trying to understand.
what are we exactly discussion?
the conditional statements in py?
operators
It is evaluating after it's True
we're reading and discussing from the docs, feel free to ask any question!
thank you
!e
x = 11
if x / 0 > 1 and x > 10:
print("Hello")
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m3[0m, in [35m<module>[0m
003 | if [31mx [0m[1;31m/[0m[31m 0[0m > 1 and x > 10:
004 | [31m~~[0m[1;31m^[0m[31m~~[0m
005 | [1;35mZeroDivisionError[0m: [35mdivision by zero[0m
!e
x = 11
if x > 10 or x / 0 > 1:
print("Hello")
false and ZeroDifError, false
or needs both.
non_null = string1 or string2 or string3
non_null
'Trondheim'
!code
sure
string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
non_null = string1 or string2 or string3
non_null
'Trondheim'
!e
code
!e```py
string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
non_null = string1 or string2 or string3
non_null
'Trondheim'
:warning: Your 3.14 eval job has completed with return code 0.
[No output]
I find dev simliar to me
Operator > Evaluation
Hi @tiny ingot welcome we're reading from:
!e
x = 11
if x < 10 or x / 0 > 1:
print("Hello")
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m3[0m, in [35m<module>[0m
003 | if x < 10 or [31mx [0m[1;31m/[0m[31m 0[0m > 1:
004 | [31m~~[0m[1;31m^[0m[31m~~[0m
005 | [1;35mZeroDivisionError[0m: [35mdivision by zero[0m
!e
x = 11
if x > 10 or x / 0 > 1:
print("Hello")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
Hello
ok im back
!e
x = 11
if x > 10 or x / 0 > 1:
print("Hello")
use !e
use it again
!e
x = 11
if x > 10 or x / 0 > 1:
print("Hello")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
Hello
!e py print("a" < "b")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
!e
print(ord('A'), ord('a'
))```
:white_check_mark: Your 3.14 eval job has completed with return code 0.
65 97