#voice-chat-text-0
1 messages Β· Page 200 of 1
I'll accept your cookies
ahhhhh the mere mention of coffee
imma head out if anyone could help just ping
you want this to keep the same functionality as it has rn? like it's working as expected, yes?
yes
@whole bear :warning: Your 3.12 eval job has completed with return code 0.
[No output]
!e
print([list(range(1+(n*10), (n*10)+10)) for n in range(0, 10)])
@whole bear :white_check_mark: Your 3.12 eval job has completed with return code 0.
[[1, 2, 3, 4, 5, 6, 7, 8, 9], [11, 12, 13, 14, 15, 16, 17, 18, 19], [21, 22, 23, 24, 25, 26, 27, 28, 29], [31, 32, 33, 34, 35, 36, 37, 38, 39], [41, 42, 43, 44, 45, 46, 47, 48, 49], [51, 52, 53, 54, 55, 56, 57, 58, 59], [61, 62, 63, 64, 65, 66, 67, 68, 69], [71, 72, 73, 74, 75, 76, 77, 78, 79], [81, 82, 83, 84, 85, 86, 87, 88, 89], [91, 92, 93, 94, 95, 96, 97, 98, 99]]
some function on this range(1, 101)
tabulate OR itertools which is better
!e
from itertools import count, islice
numbers = count(start=1)
result = [list(islice(numbers, 9)) for _ in range(11)]
for row in result:
print(row)
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
002 | [10, 11, 12, 13, 14, 15, 16, 17, 18]
003 | [19, 20, 21, 22, 23, 24, 25, 26, 27]
004 | [28, 29, 30, 31, 32, 33, 34, 35, 36]
005 | [37, 38, 39, 40, 41, 42, 43, 44, 45]
006 | [46, 47, 48, 49, 50, 51, 52, 53, 54]
007 | [55, 56, 57, 58, 59, 60, 61, 62, 63]
008 | [64, 65, 66, 67, 68, 69, 70, 71, 72]
009 | [73, 74, 75, 76, 77, 78, 79, 80, 81]
010 | [82, 83, 84, 85, 86, 87, 88, 89, 90]
011 | [91, 92, 93, 94, 95, 96, 97, 98, 99]
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/KMQ7H44HA2LMUU4DF5MOQKJD5M
!e In python 3.12, you can now do this: ```py
from itertools import batched
mylist = list(batched(range(1, 101), n=10))
print(mylist)
@stuck furnace :white_check_mark: Your 3.12 eval job has completed with return code 0.
[(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), (11, 12, 13, 14, 15, 16, 17, 18, 19, 20), (21, 22, 23, 24, 25, 26, 27, 28, 29, 30), (31, 32, 33, 34, 35, 36, 37, 38, 39, 40), (41, 42, 43, 44, 45, 46, 47, 48, 49, 50), (51, 52, 53, 54, 55, 56, 57, 58, 59, 60), (61, 62, 63, 64, 65, 66, 67, 68, 69, 70), (71, 72, 73, 74, 75, 76, 77, 78, 79, 80), (81, 82, 83, 84, 85, 86, 87, 88, 89, 90), (91, 92, 93, 94, 95, 96, 97, 98, 99, 100)]
@whole bear :white_check_mark: Your 3.12 eval job has completed with return code 0.
[(<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,), (<list_iterator object at 0x7f837cd574c0>,)]
@sour willow 
!e
i = iter(list(range(1, 101)))
print(list(zip(*([i] * 10))))
@whole bear :white_check_mark: Your 3.12 eval job has completed with return code 0.
[(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), (11, 12, 13, 14, 15, 16, 17, 18, 19, 20), (21, 22, 23, 24, 25, 26, 27, 28, 29, 30), (31, 32, 33, 34, 35, 36, 37, 38, 39, 40), (41, 42, 43, 44, 45, 46, 47, 48, 49, 50), (51, 52, 53, 54, 55, 56, 57, 58, 59, 60), (61, 62, 63, 64, 65, 66, 67, 68, 69, 70), (71, 72, 73, 74, 75, 76, 77, 78, 79, 80), (81, 82, 83, 84, 85, 86, 87, 88, 89, 90), (91, 92, 93, 94, 95, 96, 97, 98, 99, 100)]
im on 11.5 sadly
Without batched, I'd do something like this:```py
mylist = [
[10*i + j + 1 for j in range(10)]
for i in range(10)
]
Let me just check that's correct π
!e ```py
mylist = [
[10*i + j + 1 for j in range(10)]
for i in range(10)
]
print(mylist)
@stuck furnace :white_check_mark: Your 3.12 eval job has completed with return code 0.
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]
damn thanks
!e
def groupN(i, N):
return zip(*([i]*N))
print(list(groupN(list(range(1, 101)), 10)))
@whole bear :white_check_mark: Your 3.12 eval job has completed with return code 0.
[(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2), (3, 3, 3, 3, 3, 3, 3, 3, 3, 3), (4, 4, 4, 4, 4, 4, 4, 4, 4, 4), (5, 5, 5, 5, 5, 5, 5, 5, 5, 5), (6, 6, 6, 6, 6, 6, 6, 6, 6, 6), (7, 7, 7, 7, 7, 7, 7, 7, 7, 7), (8, 8, 8, 8, 8, 8, 8, 8, 8, 8), (9, 9, 9, 9, 9, 9, 9, 9, 9, 9), (10, 10, 10, 10, 10, 10, 10, 10, 10, 10), (11, 11, 11, 11, 11, 11, 11, 11, 11, 11), (12, 12, 12, 12, 12, 12, 12, 12, 12, 12), (13, 13, 13, 13, 13, 13, 13, 13, 13, 13), (14, 14, 14, 14, 14, 14, 14, 14, 14, 14), (15, 15, 15, 15, 15, 15, 15, 15, 15, 15), (16, 16, 16, 16, 16, 16, 16, 16, 16, 16), (17, 17, 17, 17, 17, 17, 17, 17, 17, 17), (18, 18, 18, 18, 18, 18, 18, 18, 18, 18), (19, 19, 19, 19, 19, 19, 19, 19, 19, 19), (20, 20, 20, 20, 20, 20, 20, 20, 20, 20), (21, 21, 21, 21, 21, 21, 21, 21, 21, 21), (22, 22, 22, 22, 22, 22, 22, 22, 22, 22), (23, 23, 23, 23, 23, 23, 23, 23, 23, 23), (24, 24, 24, 24, 24, 24, 24, 24, 24, 24), (25, 25, 25, 25, 25, 25, 25, 25, 25, 25), (26, 26, 26, 26, 26, 26, 26, 26, 26, 26
... (truncated - too long)
Full output: https://paste.pythondiscord.com/OXATW6CETKM3QXZKCYHSO5BUFM
yeah tried that gave an error
i think imma use alex's for now since thats the only one i can fully understand
well those were cool thnx to all of you guys
..
!e ```py
from itertools import count, islice
result = [list(islice(count(start=1), 9)) for _ in range(11)]
print(*result, sep='\n')
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
002 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
003 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
004 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
005 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
006 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
007 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
008 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
009 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
010 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
011 | [1, 2, 3, 4, 5, 6, 7, 8, 9]
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/TXGVSEPGPM4WZOF4DAHJQSOH4M
imma head out now , again thanks to everyone
This is approximately the same as itertools.batched (although will truncate the iterable if its length is not a multiple of n): ```py
def batched(iterable, n):
iterators = [iter(iterable)] * n
return zip(*iterators)
Understanding how the above works is a good exercise for better understanding iterators.
Btw, if you're using an older version of python, there are a bunch of recipes at the bottom of the itertools documentation for functions that may be added in later versions. https://docs.python.org/3.11/library/itertools.html?highlight=itertools#itertools-recipes
Some of them are pretty handy. I think all of them are in the third-party more-itertools package.
would itertools ( looping ) improve speed in a tkinter loop ????
no one knows
i didnt mean to be discouraging but something like this is what you have to try and find out
Harder to test something like that given all the additional overhead running
perf_counter and cProfile gang
itertools for efficiency is sparking a curioussity - seen it mentioned many times here there
sure but if the difference is not noticiable, is the optimization even worth it
itertools is just a library of functions which work on iterators
itertools is like crack and i feel like i'm cheating every time i use it
iterators are actually not an optimization technique but just a way to abstract away pure for and while loops
what you would do using iterators, would translate the a for/while loop in C
in an imperative way vs declarative way
maybe good for fast translating , 32 bit data tables ( for ASM - assembler ) , cross CPU assembler translating , CHIP-8 and others , wink wink
leetcode absolutely cannot test ones skills
most leetcode problems are solvable only if you knew the solution beforehand
That's one of the things I hate about it
It's just companies copying Google
This
Rabbit says it the best, people need to stop trying to copy FAANG
Odds are good that what they're doing do not apply to x company
does zip return a iterator of iterators or an iterator of tuples
The latter, I think, yeah.
!d zip
zip(*iterables, strict=False)```
Iterate over several iterables in parallel, producing tuples with an item from each one.
Example:
```py
>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
... print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
```...
yea but it still would allocate the size of tuple every iteration and deallocate it
!e ```py
some_list = [1, 2, 3]
some_zip = zip(some_list)
print(type(some_zip))
print(type(next(some_zip)))
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | <class 'zip'>
002 | <class 'tuple'>
i guess the internal allocator would somehow deal with repeated allocation and deallocation of this tuple
Conventionally, tuples are analogous to C structs. I.e. they're used to represent a grouping of a handful of elements of hetrogenous type.
but they wont be ever stored on the C stack
But they're sometimes used as "just an immutable list".
did you ever have a , Kim-1 , computer ? @rugged root
I just mean like, in terms of how they're intended to be thought about.
>>> some_list = ['a', 'b', 'c']
>>> some_tuple = (some_list, 'd', 'e')
>>> some_tuple[0] += 'f'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> some_tuple
(['a', 'b', 'c', 'f'], 'd', 'e')
comparing , CHIP-8 and KIM-1 , asm code @rugged root
Weird how the item is added despite the exception 
Gotta love it
!e
meats = ["ham", "pork", "beef"]
tuple_ = (meats, 3, 4)
tuple_[0].append("spam")
print(tuple_)
@rugged root :white_check_mark: Your 3.12 eval job has completed with return code 0.
(['ham', 'pork', 'beef', 'spam'], 3, 4)
Vec::with_capacity(10)
[None for _ in range(10)]
!e
meats = {"ham": 1, "pork": 2, "beef": 3}
tuple_ = (meats, 3, 4)
tuple_[0]["spam"] = 5
print(tuple_)
!e ```
l = [None]*10
print(l)
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
[None, None, None, None, None, None, None, None, None, None]
@rugged root :white_check_mark: Your 3.12 eval job has completed with return code 0.
({'ham': 1, 'pork': 2, 'beef': 3, 'spam': 5}, 3, 4)
!e ```py
import sys
print(sys.getsizeof([]))
print(sys.getsizeof([None for _ in range(10)]))
print(sys.getsizeof([None]*10))
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 56
002 | 184
003 | 136
(0..10).collect::<Vec<_>>()
so an ExactSizedIterator would know its exact length
and like that could be used for some optimizations
yea the main bottleneck is bad cache performance
due to everything being a reference
cat /dev/zero >> /dev/ram0
https://github.com/aspizu/onyo
my prog lang
its a pork dumpling
gomonade
blue gatorade + hydrocarbon + lemon_wedge
https://github.com/aspizu/onyo mascot is a onion
tread softly carry a big trunk..
wait is alex lp?
No, very different person
that profile really reminded me of lp for some odd reason
@thorn sequoia What's the context?
@stuck furnace would you let me stream
choice coffee + boxes of donuts = mighty fine bribe
I used to be LX π€
What do you want to stream?
coding
Sure π
thanks
!stream 939196353362419722 1h
β @whole bear can now stream until <t:1697138220:f>.
ah still on that instant coffee grind?
wm?
shod
I gave up caffeine for a while, but gave in and started drinking it again.
theprimagen
Has anyone had an issue on windows where your time keeps getting 1 hour out of sync? 
i am one of the people of all time
Yeah it's really weird.
Erm, we do have summer time. I can't remember whether it's in the summer or winter where we're off from UTC by one hour.
help
I forgot what this is called
@oblique ridge
yo
def power(base,power_num):
result = 1
for i in range(power_num):
if power_num == 0:
result = 1
elif power_num == 1:
result = base
elif power_num > 1:
result = result * base
return result
print(power(2,3))
is there a library to parse derive(Debug) from rust in python?
anyone knows how to replace the python version in windows like i have python 11 so how can i do into python 12
def power(a, n):
result = 1
for _ in range(n):
result *= a
return result
but it's the exact same idea
but, wouldn't you want to do your if power_num checks outside your loop?
would this work: https://pypi.org/project/rustimport/. ?
Huh, neat
I'll be AFK
whats the output of round 1.5?
>>> round(1.5)
2
>>> round(2.5)
2
what why
floating point arithmetic magic
Crappy magic
1.50 should round up to 2
decimal 2.5 should also round up to 3
but we're working with floats, not decimals
>>> round(Decimal(1.5))
2
>>> round(Decimal(2.5))
2
The king receives a lesson in government from Dennis...
Alternative Link from ThePirateBay: https://thepiratebay.org/torrent/9066073/Monty.Python.and.the.Holy.Grail.1975.1080p.BluRay.x264.anoXmous
Original Link (Dead, for archival purposes only): http://kickass.to/monty-python-and-the-holy-grail-720p-best-quality-murdoc47-t6439813.html
https:/...
https://www.cameo.com/labeast
Do you want a Personalized L.A. BEAST Video Shout Out??
Happy Birthday Wishes, Good Luck before the big game,
or just a simple Have A Good Day?!?!?
Check out my Cameo Profile Here:
Support On PATREON:
https://www.patreon.com/LABEAST
BEST OF THE BEST LA BEAST VIDEOS PLAYLIST:
https://www.youtube.com/playlist?lis...
im trying to solve the round problem but i got stuck lol
throw that thing away and let us know where
example 1.51
take 1.51 as X
y = x/x with only 2 characters thas equals 1.5
take 1.51 and divide by 1.5
1.50/1.5 = 1
1.51/1.5 = 1.006
so you can solve this
this
how do you solve that then if your number has 200000 decimals
You use alternative ways of representing the number
even if i compare them?
will be the same
oh
sorry im new with this lol
didnt knew " " = ' '
dm code
lol
Floating-point arithmetic is considered an esoteric subject by many people
oh they talk about the rounding error
i think w3schools doesnt have all the methods at least if you dont look for them for youself
Use regex π
@oblique ridge also for neg numbers:```py
def power(base,power_num):
result = 1
for i in range(power_num):
if power_num == 0:
result = 1
elif power_num == 1:
result = base
elif power_num > 1:
result = result * base
for _ in range(power_num, 0):
if power_num < 1:
result = result / base
return result
print(power(2,-3))
yo what up
nice
my wife customized my keyboard to encourage me to coding lol
how does any of that add up
idk
but someone supporting you is cool
im stuck with some stuff and is hard to keep learning
i hate the loops
hello sir
whats wrong with py print(2 ** -3)
ahh he told me to not use it for learnin purposes
valid reason lol
haha
nice function tho
the if power_num == 0 is actually impossible to happen tho
yeah
yeah if u put 2,0 for i in (0) does nothing
give me smt to do to up my lvl in coding
wait rly?
why are you speaking here if not in vc
lol bc the chats were here
life
is roblox
NAHH
WTFF
true..
liufe is defo python
wrong chat
nahhhh wrong chat
guys
do you wannna see my discord bot?
can you give mea star
pls
yay
not bad
i broke python wtf
whats that
words?
oh hangman
i done fucked up my python
install
smh
nah
we cant
we need a role
still cant stream
can we call a mod
@rugged root
Hello π
oh cmon on
I may have been lurking in #python-discussion
Erm, who wants to share screen sorry?
Alright
My minds blanked an I've forgotten the command one sec π
!stream 133817562646577153 1h
β @alpine crow can now stream until <t:1697147519:f>.
Windows?
yes
hah how?
What happens when you try to uninstall?
@toxic arch Try the steps in this SO answer: https://superuser.com/a/1301610
Let me know if that works.
damn rip my modules i installed then
hmm i wonder if i can find my old
coin counter thing
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
yo i just made a python script that helps you find any info about any topic its really helpful for research. lmk if you want the link i promise to you its not malicious i swear on my life i just made it safe and helpful. i just want to make researching easier. + it gives you MLA citations for each article without needing easybib or an equivalent
I originally made it for myself but put it up on github
nope @stuck furnace it didnt work
You followed all the steps and there was no change?
yep i deleted the python folder and its still saing that error
in appdata
Ah right. And you tried repairing after deleting that folder?
Did you have python installed on a different drive?
yeah i did recently
but its not plugged in
i dont have access to it right now
Oh ok. So the drive that python was installed on is no longer connected to your PC?
yes
guys how many space i need for all python methods
I've found this advice, but for nodejs: https://stackoverflow.com/questions/41364644/can-not-use-or-uninstall-node-js
what
just in case someone would get a tatoo of them
lol
do you think i have plenty space on my body, only visible parts for me
All python methods 
there was a python there, i deleted it but
its still there
i mean
the error
and what about methods and simple examples
small ones
Β―_(γ)_/Β―
maybe only the name
and if i see them ill try to memorize everything
i will try and let you know exactly how much
im using this btw https://www.w3schools.com/python/python_reference.asp
u can use this too
oh yeah, thats better
i had problems calling stuff from a dictionary on another module
and w3schools doesnt have a lot of explanation
yea, s-lang would work
get s-lang tattooed much easier
where on earth does it store this?
Erm, I'm not sure I know enough about Windows to advise on editing the registry. Perhaps try this: https://superuser.com/a/1482475
i don't really use windows, not sure
whats s lang?
Try the troubleshooter in the linked answer, and let me know if anything changes.
Β―_(γ)_/Β―
Code jam is once a year in the summer. PyWeek is twice a year.
PyWeek isn't actually organised by us but the code jam is.
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
s-lang (snake-language)
the best programming language, all functions are different lengths of "s"s and any other letter beside "s" are seen as a comment
"hello world" would be:
s ('s+8 s+5 s+12 1s+2 s+0 s+15 s+23 s+15 s+18 s+12 s+4')
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
from random import choice
while True:
input("Enter Rock/Paper/Scissors:")
print(choice(["You win!", "You lose", "draw"]))
s+8 = h?
a= 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8
whoever told me to install python to a disk
dont do that
any way to get the modules like tkinter in a python embdeded paCKAGE?
i found the disk
As in a single exe?
no just the .zip
it says tkinker not found
spooky music
in reccomended
why not
@alpine crow
its thew namer of the savefile in lbp
look
i had that question too
pygame has sound?
playsound module for tkinter?
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
import winsound
duration = 1000 # milliseconds
freq = 440 # Hz
winsound.Beep(freq, duration)
this works
yay my python fixed now
Did the troubleshooter actually work?
no i just found the disk
and uninstalled it
Ah right I see
sad though
sigh i told them soo many times to install python on the pcs
but they wont
.xkcd 710
rabbit hole
haha
nah cmd dubs
how
its just do
!e py def collatz(n): if n == 1: return 1 elif n % 2 == 0: print(n) return collatz(n/2) else: print(n) return collatz(3*n+1) collatz(4) collatz(21)
@alpine crow :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 4
002 | 2.0
003 | 21
004 | 64
005 | 32.0
006 | 16.0
007 | 8.0
008 | 4.0
009 | 2.0
!e
def collatz(n):
if n == 1:
return 1
elif n % 2 == 0:
print(n)
return collatz(n/2)
else:
print(n)
return collatz(3*n+1)
collatz(4)
collatz(23423423)
@toxic arch :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 4
002 | 2.0
003 | 23423423
004 | 70270270
005 | 35135135.0
006 | 105405406.0
007 | 52702703.0
008 | 158108110.0
009 | 79054055.0
010 | 237162166.0
011 | 118581083.0
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/CRMLNY7GGGH7VNEYZF6Q2OUWEY
In computability theory, the halting problem is the problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running, or continue to run forever. The halting problem is undecidable, meaning that no general algorithm exists that solves the halting problem for all possible programβin...
YESSSSSSS
what is?
this problem can't be solved by computers bc of the halting problem
i swear it was working fine before
damn
import sys
lines = open(sys.argv[1]).read().split('\n')
if lines == []: exit(0)
height = max([len(line) for line in lines])
width = height + len(lines) - 1
matrix = [[' ' for x in range(width)] for y in range(height)]
for i, line in enumerate(lines):
llen = len(line)
for j, char in enumerate(line):
matrix[height-j-1][i+j] = char
for line in matrix:
print(''.join(line))
hello there
test
this is the diagonalizer
to
r
e
z
i
l
a
n
o
g
a
i
d
e e
r h
e t
h
t s
i
o
lts
lsi
eeh
htt
@alpine crow brother do you follow the calling convetions of c/c++
in your custom code thing
man
tkinker is finicky
time to make a search bar
11:01pm here
π
@pulsar light what ya trying to do with this
why is there a extra bracket here
thje blue one
its extra
no
that the yellow one
slowly coming together...
yess looks good
http://handmadehero.org is a project designed to capture and teach the process of coding a complete, professional-quality game from scratch.
cya
nice
wait
let me watch
of course
i got anti adblock
but i got a filtere to bypass it
ez
http://handmadehero.org is a project designed to capture and teach the process of coding a complete, professional-quality game from scratch.
I didn't make it, but liked the idea
hi guys
remember when Unity changed the pricing scheme on their licenses to charge game developers per install?
and their CEO quit his job a few months after the decision because it backfired
he thought he was so clever, such a big brain and financially-driven economist mind..
and then he quit
F that guy
GAVILΓN II (Visualizer) - Peso Pluma, Tito Double P
Double P RecordsΒ©
βΈ ESCUCHA / LISTEN GΓNESIS: https://orcd.co/ppgenesis
βΈMΓΊsica
InterpretaciΓ³n - Peso Pluma, Tito Double P
ComposiciΓ³n - Jesus Roberto Laija Garcia
ProducciΓ³n - JesΓΊs IvΓ‘n Leal Reyes βParkaβ, JesΓΊs Roberto Laija GarcΓa
βΈLetra
Chau!
Ya me escucharon por ahΓ
mitotes han ...
@naive ravine π
cc
coucou
i want help in program
but the question is with french language
Ecrire un programme en Python qui demande Γ l'utilisateur de saisir deux nombres a et b et de lui afficher leur maximum.
!d max
max(iterable, *, key=None)``````py
max(iterable, *, default, key=None)``````py
max(arg1, arg2, *args, key=None)```
Return the largest item in an iterable or the largest of two or more arguments.
If one positional argument is provided, it should be an [iterable](https://docs.python.org/3/glossary.html#term-iterable). The largest item in the iterable is returned. If two or more positional arguments are provided, the largest of the positional arguments is returned.
There are two optional keyword-only arguments. The *key* argument specifies a one-argument ordering function like that used for [`list.sort()`](https://docs.python.org/3/library/stdtypes.html#list.sort). The *default* argument specifies an object to return if the provided iterable is empty. If the iterable is empty and *default* is not provided, a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) is raised.
fonction max
!e py print(max(10, 5))
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
10
!e py print(5 > 10)
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
False
!e py print(5 < 10) print(5 == 10)
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | True
002 | False
!e py if 5 > 10: print('A') else: print('B')
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
B
!e
code
!e print(max(10,200))
@naive ravine :white_check_mark: Your 3.12 eval job has completed with return code 0.
200
!e py arr = [5, 1, -10, +4, 10] print(max(arr))
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
10
thnks
!e py float('*#Β£@1gh')
@somber heath :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | float('*#Β£@1gh')
004 | ValueError: could not convert string to float: '*#Β£@1gh'
!e py try: float('*#Β£@1gh') except ValueError: print('A')
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
A
!e py v = 0 while v != 5: print(v) v += 1 print('.')
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | .
!e py for i in range(5): print(i)
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
@somber heath :warning: Your 3.12 eval job timed out or ran out of memory.
[No output]
!e
result = ""
for i in range (5) :
result += f"{i}, "
result = result[:-1]
print (result)
@fervent grail :white_check_mark: Your 3.12 eval job has completed with return code 0.
0, 1, 2, 3, 4,
!e
result = ""
for i in range (5) :
result += f"{i}, "
result = result[:-2]
print (result)
@fervent grail :white_check_mark: Your 3.12 eval job has completed with return code 0.
0, 1, 2, 3, 4
!e py v = 0 while v != 5: print(v) v += 1 if v == 2: break print('.')
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 1
003 | .
!e
result = ""
c = 0
whiel 5 > c :
result += f"{c}, "
c += 1
result = result[:-2]
print (result)
@fervent grail :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 3
002 | whiel 5 > c :
003 | ^
004 | SyntaxError: invalid syntax
!e
result = ""
c = 0
while 5 > c :
result += f"{c}, "
c += 1
result = result[:-2]
print (result)
@fervent grail :white_check_mark: Your 3.12 eval job has completed with return code 0.
0, 1, 2, 3, 4
!e
result = ""
c = 0
while 5 > c :
result += f"{c}, "
c += 1
if c == 3 : break
result = result[:-2]
print (result)
@fervent grail :white_check_mark: Your 3.12 eval job has completed with return code 0.
0, 1, 2
SyntaxWarning: invalid decimal literal
print(tabulate([[10*i+j+1for j in range(10)] for i in range(10)], tablefmt="grid"))
anyone know how i can fix this?
oops wrong channel
1for?
No.
yeah got it thnx though
it runs anyway
!e py 1for
@somber heath :x: Your 3.12 eval job has completed with return code 1.
001 | /home/main.py:1: SyntaxWarning: invalid decimal literal
002 | 1for
003 | File "/home/main.py", line 1
004 | 1for
005 | ^^^
006 | SyntaxError: invalid syntax
Oh, okay.
!e
print([[10*ifor j in range(1)]for i in range(2)])
@sour willow :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | print([[10*ifor j in range(1)]for i in range(2)])
003 | ^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
Are you sure you mean ^ and not ** ?
code
why would that be an arg if its only gonna support 3.12 lol
I suspect there's a disparity between that description and what is actually implemented.
I may also have goofed the syntax of it.
<stdin>:1: SyntaxWarning: invalid decimal literal
did it get promoted to an error?
!e
[1for _ in []]
@vocal basin :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | /home/main.py:1: SyntaxWarning: invalid decimal literal
002 | [1for _ in []]
no, not yet
insane
oh
nvm
i didnt see the except
I get that, too, sometimes. "Oh, right, completely obvious thing I completely missed right there."
hey hi @glass atlas
@glass atlas π
Hello
!voice
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
Hello
class MyClass:
def __init__(self, ...): # <-- Show me this.
...
MyClass(...) # <-- Show me this.```
I don't do DM stuff.
Bar exceptions.
Just the lines I indicated.
ayy good stuff. i have a collatz problem for you
i did it
I need to see the class you're trying to use and the place where you're trying to create an instance of it.
A website dedicated to the fascinating world of mathematics and programming
That's part of the traceback.
try this out. very fun problem with learning optimization @pulsar light
Okay, and the instantiation call?
somebody solved this?
ye this is from a site where all the problems are solvable. some of them are insanely tough, but many of the first problems are relatively easy
.... ok ill give it a try
Show me what you're doing where you gopy Material(...)
@oblique ridge come vc
also this isn't specific to this problem. you should test out your solutions on smaller sets you can confirm manually to see if what you wrote works in a reasonable time before doing it on a larger set like the thing the problem asks
finishing up a call rn
I can try this!
@pulsar light π
absolutely, give it a go
kk
either of yall lmk if you need help
printing the ans or storing in a list?
the final solution is one number. so you'd wanna print that to see what it is
if you create an account with the site, you're actually able to submit the answer you get to confirm. if you don't wanna do that, just ask me if your answer is right and i can confirm
we need to loop until num becomes 1 and apply odd even comdition?
u want the code?
#3n+1
import time
t= True
a = True
print(''' Hello there, this is a programme that you use to test some numbers in Collatz conjecture.
Incase you weren't familiar with it here is what it does:
β’ First, you type a positive number.
β’ If the number is even, you divide it by 2.
β’ If the number is odd, you multiply by 3 and add 1.
β’ The conjecture states that there is no number that wont end up in 1 if you applied this operations to it.
You think you can find a number that can't satisfy this conjecture?. Goodluck!
If you want to exit type 0.
''')
while t:
n = int(input('Type a number : '))
if n ==0:
print(' \n \n Quit. \n \n')
break
print(n)
while a:
if n % 2 == 0:
n //= 2
print(n)
time.sleep(0.1)
else:
n = 3*n + 1
print(n)
time.sleep(0.1)
if n ==1:
break
```
ye if you send code it's nicer, but the important part is coming up with the solution
Great!
ask one more problem bro!
oh did you solve? π
this is another nice one. should be easier
https://projecteuler.net/problem=7
A website dedicated to the fascinating world of mathematics and programming
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | Hello. I am Peter.
002 | Hello. I am Paul.
you can solve this one slowly, but optimizing is the better fun
!paste @rain salmon
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Post all the code.
For the pastebin? How big is it?
Search for any mention of Material( in your code.
The traceback/error message might give you a clue as to the line it's snagging on.
||```py
def SieveOfEratosthenes(n):
prime = [True for i in range(n+1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
count=0
for p in range(2, n+1):
if prime[p]:
count+=1
# print(p)
if count==n**0.5:
print(p)
SieveOfEratosthenes(10001*10001)
Right, so the Material class is asking to be provided with seven arguments in the call. The call is being given five arguments.
!e ```py
class MyClass:
def init(self, a, b, c, d, e, f, g):
print('Success')
MyClass(1, 2, 3, 4, 5, 6, 7)```
@somber heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
Success
!e ```py
class MyClass:
def init(self, a, b, c, d, e, f, g):
print('Success')
MyClass(1, 2, 3, 4, 5)```
@somber heath :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 5, in <module>
003 | MyClass(1, 2, 3, 4, 5)
004 | TypeError: MyClass.__init__() missing 2 required positional arguments: 'f' and 'g'
@edgy viper ||104743|| Answer?
@rain salmon This is essentially what your problem is.
ah i used the sieve for problem 10
func main() {
primes := utils.PrimeSieve(2_000_000)
sum := utils.SumInts(primes)
fmt.Println(sum)
}
```lol
!e py 'abc' % 123
@somber heath :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | 'abc' % 123
004 | ~~~~~~^~~~~
005 | TypeError: not all arguments converted during string formatting
!e py 123 % 456
@somber heath :warning: Your 3.12 eval job has completed with return code 0.
[No output]
!e
print(3*'a')
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
aaa
!e ```py
print(3+'a')
@oblique ridge :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print(3+'a')
004 | ~^~~~
005 | TypeError: unsupported operand type(s) for +: 'int' and 'str'
im bad at math π
def is_prime(num):
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
i += 6
return True
def find_primes(n):
prime_list = []
num = 2 # Start with the first prime number
while len(prime_list) < n:
if is_prime(num):
prime_list.append(num)
num += 1
return prime_list
# Example usage:
n = 10 # Change this to the number of prime numbers you want
prime_numbers = find_primes(n)
print(prime_numbers)
!e ```py
def add(a, b):
return a + b
print(add(5, 4))
print(add(3, 2))
print(add(2))```
@somber heath :x: Your 3.12 eval job has completed with return code 1.
001 | 9
002 | 5
003 | Traceback (most recent call last):
004 | File "/home/main.py", line 6, in <module>
005 | print(add(2))
006 | ^^^^^^
007 | TypeError: add() missing 1 required positional argument: 'b'
!e
def is_prime(num):
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
i += 6
return True
def find_primes(n):
prime_list = []
num = 2 # Start with the first prime number
while len(prime_list) < n:
if is_prime(num):
prime_list.append(num)
num += 1
return prime_list
# Example usage:
n = 10 # Change this to the number of prime numbers you want
prime_numbers = find_primes(n)
print(prime_numbers)
@obsidian dragon :white_check_mark: Your 3.12 eval job has completed with return code 0.
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
hmm i think it can be simplified with nested loop
Listen to "Karma Chameleon" by the Culture Club, and sing along with the HD lyrics on screen!
Remember! I DO NOT own this song or the background image! ALL RIGHTS belong to their respectful owners!
Image source: https://mewallpaper.com/687-purple-night-sky-wallpaper-download-free
Culture Club YT: https://www.youtube.com/channel/UCdfnMLE8x9...
!e
def is_prime(num):
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
i += 6
return True
def find_primes(n):
prime_list = []
num = 2 # Start with the first prime number
while len(prime_list) < n:
if is_prime(num):
prime_list.append(num)
num += 1
return prime_list
# Example usage:
n = 10000 # Change this to the number of prime numbers you want
prime_numbers = find_primes(n)
print(prime_numbers)
@obsidian dragon :white_check_mark: Your 3.12 eval job has completed with return code 0.
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 12
... (truncated - too long)
Full output: https://paste.pythondiscord.com/FYOWLKQASGH5LKF73QTOFRDSWM
!e ```py
def is_prime(n: int) -> bool:
if n < 2:
return False
for i in range(2, int(n ** .5) + 1):
if n % i == 0:
return False
return True
prime = 0
i = 2
while prime < 10_0001:
if is_prime(i):
prime += 1
print(i)
i += 1
Sorry, an unexpected error occurred. Please let us know!
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
!e ```py
def is_prime(n: int) -> bool:
if n < 2:
return False
for i in range(2, int(n ** .5) + 1):
if n % i == 0:
return False
return True
prime = 0
i = 2
while prime < 10_0001:
if is_prime(i):
prime += 1
print(i)
i += 1
@oblique ridge :x: Your 3.12 eval job timed out or ran out of memory.
001 | 2
002 | 3
003 | 5
004 | 7
005 | 11
006 | 13
007 | 17
008 | 19
009 | 23
010 | 29
011 | 31
... (truncated - too many lines)
Full output: unable to upload
u rn:
oh i went one sigfig higher lol
i'm stupid
!e ```py
def is_prime(n: int) -> bool:
if n < 2:
return False
for i in range(2, int(n ** .5) + 1):
if n % i == 0:
return False
return True
prime = 0
i = 2
while prime < 10_001:
if is_prime(i):
prime += 1
print(i)
i += 1
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 2
002 | 3
003 | 5
004 | 7
005 | 11
006 | 13
007 | 17
008 | 19
009 | 23
010 | 29
011 | 31
... (truncated - too many lines)
Full output: unable to upload
!e
def is_perfect_number(n):
divisors = [1]
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
divisors.extend([i, n // i])
return sum(divisors) == n
def find_perfect_numbers_in_range(start, end):
perfect_numbers = []
for number in range(start, end + 1):
if is_perfect_number(number):
perfect_numbers.append(number)
return perfect_numbers
start_range = 1 # Define your start range here
end_range = 1000000 # Define your end range here
perfect_numbers_in_range = find_perfect_numbers_in_range(start_range, end_range)
print("Perfect numbers in the range [{}, {}]: ".format(start_range, end_range))
print(perfect_numbers_in_range)
@obsidian dragon :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | Perfect numbers in the range [1, 10000]:
002 | [1, 6, 28, 496, 8128]
#prime
'''
can we use the mod != 0 and lets say 'n' is the prime num before it ,so if p % n,n-1,n-2,...,3,2 and also lets use the reverse and the list[1:]
'''
@obsidian dragon :warning: Your 3.12 eval job timed out or ran out of memory.
[No output]
#prime
'''
can we use the mod != 0 and lets say 'n' is the prime num before it ,so if p % n,n-1,n-2,...,3,2 and also lets use the reverse and the list[1:]
'''
!e
print('Hello, S-lang is better')
@haughty fog :white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello, S-lang is better
i know
!code
i = 5
y = 1
prime = 0
for x in range(1, i):
if i % x == 0:
prime += 1
if prime > 1:
print(i, " not prime")
else:
print(i, " is prime")
Watch the tutorial series I wrote down when you've recovered.
It'll get you situated.
!e ```py
i = 5
y = 1
prime = 0
for x in range(1, i):
if i % x == 0:
prime += 1
if prime > 1:
print(i, " not prime")
else:
print(i, " is prime")
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
5 is prime
mods could I stream please
!stream 939196353362419722
β @whole bear can now stream until <t:1697207489:f>.
Hey Focus
@grave hollow π
@proper sparrow π
i have a oled display
OLED or OILED? You decide!
i am oiled
Human Oil sounds like a product out of Rick and Morty.
@amber raptor have you had any water π° today?
Interestingly, looking at custom router firmware, there aren't many for ones that have 802.11ax or Wifi 6
When it comes to performance, the Lenovo G27-20 gaming monitor's got game. Let's start with its 27-inch 1920 x 1080 full HD resolution In-Plane Switching (IPS) panel display that delivers startlingly life-like lighting effects to gameplay in a luminous 400 cd/m2, thanks to HDR decoding on-the-fly...
I don't want to put a custom on it, just interesting
thats crazy
it looks like an inverted cave spider from Minecraft
@gentle flint are you in the VC later?
i've had actually this happen lol
guy was a startup and the takehome was to build this app that was exactly what they wanted
the thing is, if its a good challenge, id do it
issue is it was something relatively easy to do, but the asks were so specific, it was pretty obvious they wanted a starting point from me
its not done yet though
I'm here now
won't be later
i can tell you it's a million times better than a UI i'd make
this is maybe really late for this prime shiz
you can make the program more efficient if the program stop when there is more than two factor
i = 3
is_prime = True
prime = 0
for x in range(1, i):
if i % x == 0:
prime += 1
if prime >= 2:
is_prime = False
break
@midnight temple Yo
Sup
im just checking if my headset works guys dw
wait i dont get it
Divide the number by 2. If the result is a whole number, the number is not prime.
Divide the number by prime numbers, such as 3, 5, 7, and 11. If the number is divisible by any of these numbers, it is not prime.
Find the biggest perfect square less than or equal to the number.
Write out all the primes less than or equal to the perfect square.
Test if the number is divisible by each of the primes on your list. If the number is divisible by any of the primes, it is not prime.
Hmm
John Harvey Kellogg (February 26, 1852 β December 14, 1943) was an American businessman, inventor, physician, and advocate of the Progressive Movement. He was the director of the Battle Creek Sanitarium in Battle Creek, Michigan, founded by members of the Seventh-day Adventist Church. It combined aspects of a European spa, a hydrotherapy instit...
This guy was really interesting. And I was right, it was his brother that invented breakfast cereal corn flakes
there is a movie about this ...
from prime numbers to old fart jokes .... its my first coffee
no jokes allowed in the MATH room ..... but here is ok
Yeah don't please
I'm sorry
It's disruptive
ππΎ
Thanks
Joseph Pujol (June 1, 1857 β August 8, 1945), better known by his stage name Le PΓ©tomane (, French pronunciation: [lΙpetΙman]), was a French flatulist (professional farter) and entertainer. He was famous for his remarkable control of the abdominal muscles, which enabled him to seemingly fart at will. His stage name combines the French verb pΓ©ter...
prime number is a number that can be divided by itself and 1
so if there is other number that can divide it
then it is not prime
so if the factor is more than 2, then its not prime
Right that I get
He was famous for his remarkable control of the abdominal muscles.....
hmm you could do that
what have you started
i = 3
is_prime = True
for x in range(2, i):
if i % x == 0:
is_prime = False
i think a religion has started from less
wow thats way better
are we still on this? what is the goal of the code?
you can do one better
instead of checking all the way up to 1 less than i, you can check up to the square root of i
renn and stimpy -- logs...
because if a number has a factor, it's got 2
mental subversion
so 15 is divisible by 3 and 5
and those are just above and below sqrt(15)
sup prop, hem, potato, magic
so ```py
i = 3
is_prime = True
for x in range(2, int(i**.5) + 1):
if i % x == 0:
is_prime = False
def is_prime(n: int) -> bool:
if n < 2:
return False
for i in range(2, int(n ** .5) + 1):
if n % i == 0:
return False
return True
would you call what your discussing , numerical analysis ?
sameeeee
tortoise and hare -- how about xerces ( zerk see ) problem of the messenger
Gojo's power
!d math.isqrt
math.isqrt(n)```
Return the integer square root of the nonnegative integer *n*. This is the floor of the exact square root of *n*, or equivalently the greatest integer *a* such that *a*Β² β€ *n*.
For some applications, it may be more convenient to have the least integer *a* such that *n* β€ *a*Β², or in other words the ceiling of the exact square root of *n*. For positive *n*, this can be computed using `a = 1 + isqrt(n - 1)`.
New in version 3.8.
didnt feel like importing math π©
good morning guys
int(n ** .5) gets quite wrong with large numbers
... though at that point you wouldn't be exhaustively checking divisors
(hopefully)
Xerxes
who was the tall guy in the movie 300
duck search --- i had to learn how to spell it
-.+0
I did know that.
Because of course I do
Why do I know these things
In computing, the Two Generals' Problem is a thought experiment meant to illustrate the pitfalls and design challenges of attempting to coordinate an action by communicating over an unreliable link. In the experiment, two generals are only able to communicate with one another by sending a messenger through enemy territory. The experiment asks ho...
this a old one --- but i cant find the xerces one - maybe its called something else
room died - was it the turtle fart...
i just realized turtles and politicians have something in common...
imoport sevseg
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
print(1)
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Al Sweigart - The Big Book of Small Python Projects_ 81 Easy Practice Programs (2021, No Starch Press) -
!e ```py
representations = {
'0': ('###', '# #', '# #', '# #', '###'),
'1': (' #', ' #', ' #', ' #', ' #'),
'2': ('###', ' #', '###', '# ', '###'),
'3': ('###', ' #', '###', ' #', '###'),
'4': ('# #', '# #', '###', ' #', ' #'),
'5': ('###', '# ', '###', ' #', '###'),
'6': ('###', '# ', '###', '# #', '###'),
'7': ('###', ' #', ' #', ' #', ' #'),
'8': ('###', '# #', '###', '# #', '###'),
'9': ('###', '# #', '###', ' #', '###'),
'.': (' ', ' ', ' ', ' ', ' #'),
}
def seven_segment(number):
# treat the number as a string, since that makes it easier to deal with
# on a digit-by-digit basis
digits = [representations[digit] for digit in str(number)]
# now digits is a list of 5-tuples, each representing a digit in the given number
# We'll print the first lines of each digit, the second lines of each digit, etc.
for i in range(5):
print(" ".join(segment[i] for segment in digits))
seven_segment(420.69)
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | # # ### ### ### ###
002 | # # # # # # # #
003 | ### ### # # ### ###
004 | # # # # # # #
005 | # ### ### # ### ###
.
# ### ### ###
# # # # # #
### # # ###
# # # # #
### ### # ###
# # ### ### ### ###
# # # # # # # #
### ### # # ### ###
# # # # # # #
# ### ### # ### ###
That's really cool. Hadn't thought about arranging the characters like that to store them for ascii art
exactly i said that too
definitely beats this
Oh god
hes right
!e ```py
from datetime import datetime
now = datetime.now()
print(now)
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
2023-10-13 17:43:01.811866
informatics
!e
from datetime import timedelta
countdown = timedelta(seconds=10)
while countdown >= timedelta(seconds=0):
countdown -= timedelta(seconds=1)
print(countdown)
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0:00:09
002 | 0:00:08
003 | 0:00:07
004 | 0:00:06
005 | 0:00:05
006 | 0:00:04
007 | 0:00:03
008 | 0:00:02
009 | 0:00:01
010 | 0:00:00
011 | -1 day, 23:59:59
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/EHUHVLBWYZVDCJAPTWKVEZT5VE
!e
seven_segment = lambda number: print(*[" ".join(segment[i] for segment in [{'0': ('###', '# #', '# #', '# #', '###'),'1': (' #', ' #', ' #', ' #', ' #'),'2': ('###', ' #', '###', '# ', '###'),'3': ('###', ' #', '###', ' #', '###'),'4': ('# #', '# #', '###', ' #', ' #'),'5': ('###', '# ', '###', ' #', '###'),'6': ('###', '# ', '###', '# #', '###'),'7': ('###', ' #', ' #', ' #', ' #'),'8': ('###', '# #', '###', '# #', '###'),'9': ('###', '# #', '###', ' #', '###'),'.': (' ', ' ', ' ', ' ', ' #')}[digit] for digit in str(number)]) for i in range(5)], sep="\n")
seven_segment(420.69)
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | # # ### ### ### ###
002 | # # # # # # # #
003 | ### ### # # ### ###
004 | # # # # # # #
005 | # ### ### # ### ###
def foo(bar):
return bar * bar
# is equal to
foo = lambda bar: bar * bar
!e ```py
def square(a):
return a ** 2
nums = [1, 2, 3, 4, 5]
print(*map(square, nums))
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
1 4 9 16 25
!e ```py
nums = [1, 2, 3, 4, 5]
print(*map(lambda a: a ** 2, nums))
@oblique ridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
1 4 9 16 25
iterable has
__next__
in it
method
@oblique ridge how did you get that other role
advent of code
can you give me stream permissions?
string.upper()
upper is a method
str.__next__()
for i in str:
i = next(str)
def next(foo):
return foo.__next__()
i forgot
!e
class Hello:
def __init__(self):
self.i = 1
def __next__(self):
self.i += 1
if self.i == 4:
raise StopIteration()
return self.i
for i in Hello:
print(i)
@toxic arch :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 10, in <module>
003 | for i in Hello:
004 | TypeError: 'type' object is not iterable
!e
code
!eval [python_version] <code, ...>
Can also use: e
Run Python code and get the results.
This command supports multiple lines of code, including formatted code blocks. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
The starting working directory /home, is a writeable temporary file system. Files created, excluding names with leading underscores, will be uploaded in the response.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside them.
Currently only 3.12 version is supported.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!
!e
class Hello:
def __init__(self):
self.i = 1
def __iter__ (self):
return self
def __next__(self):
self.i += 1
if self.i == 4:
raise StopIteration()
return self.i
for i in Hello():
print(i)
@toxic arch :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 10, in <module>
003 | for i in Hello():
004 | TypeError: 'Hello' object is not iterable
sad
!e
class Hello:
def __init__(self):
self.i = 1
def __iter__ (self):
return self
def __next__(self):
self.i += 1
if self.i == 4:
raise StopIteration()
return self.i
for i in Hello():
print(i)
@toxic arch :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 2
002 | 3
!e
print(True > True < False)
@shrewd olive :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print(true > true < false)
004 | ^^^^
005 | NameError: name 'true' is not defined. Did you mean: 'True'?
!e
print(True > True < False)
@shrewd olive :white_check_mark: Your 3.12 eval job has completed with return code 0.
False
!e
print(True >= True < False)
@toxic arch :white_check_mark: Your 3.12 eval job has completed with return code 0.
False
!e
print(True <= True < False)
@toxic arch :white_check_mark: Your 3.12 eval job has completed with return code 0.
False
!e
print(True >= True > False)
@toxic arch :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
!e
print(True == True > False)
@shrewd olive :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
@sage cape π
!voice
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
but I need help with a quick thing in Python
so can we do a private call?
I need help with moving a file from my downloads to my user directory
\\ have os call bash commands to move files from ~/downloads/ --> ~/
?
import shutil
import os
# Define the source and destination directories
source_directory = 'source_folder'
destination_directory = 'destination_folder'
# List the files in the source directory
files = os.listdir(source_directory)
# Iterate through the files and move them to the destination directory
for file in files:
source_path = os.path.join(source_directory, file)
destination_path = os.path.join(destination_directory, file)
try:
shutil.move(source_path, destination_path)
print(f"Moved {file} to {destination_directory}")
except Exception as e:
print(f"Failed to move {file}: {str(e)}")
via chatgpt
non?
!rule 10
ah
ur on winblows
I have a FIT file and I am trying to move it to my designated user directory
you should use arch linux gentoo
!d pathlib
New in version 3.4.
Source code: Lib/pathlib.py
This module offers classes representing filesystem paths with semantics appropriate for different operating systems. Path classes are divided between pure paths, which provide purely computational operations without I/O, and concrete paths, which inherit from pure paths but also provide I/O operations.
If youβve never used this module before or just arenβt sure which class is right for your task, Path is most likely what you need. It instantiates a concrete path for the platform the code is running on.
Pure paths are useful in some special cases; for example:
!d shutil
Source code: Lib/shutil.py
The shutil module offers a number of high-level operations on files and collections of files. In particular, functions are provided which support file copying and removal. For operations on individual files, see also the os module.
Warning
Even the higher-level file copying functions (shutil.copy(), shutil.copy2()) cannot copy all file metadata.
On POSIX platforms, this means that file owner and group are lost as well as ACLs. On Mac OS, the resource fork and other metadata are not used. This means that resources will be lost and file type and creator codes will not be correct. On Windows, file owners, ACLs and alternate data streams are not copied.
!d open
open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)```
Open *file* and return a corresponding [file object](https://docs.python.org/3/glossary.html#term-file-object). If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError) is raised. See [Reading and Writing Files](https://docs.python.org/3/tutorial/inputoutput.html#tut-files) for more examples of how to use this function.
*file* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to `False`.)
also wtf am i doing wrong here
I dont understand any of this
all I want is to extract data from a FIT file but it isn't doing it's job
@vocal basin :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | r'a\'
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 1)
!e
print(r'a\\')
@vocal basin :white_check_mark: Your 3.12 eval job has completed with return code 0.
a\\
there isn't a way around
Well
!e
print(r'a\
')
@vocal basin :white_check_mark: Your 3.12 eval job has completed with return code 0.
a\
>>> Path("C:\\Users\\User\\")
WindowsPath('C:/Users/User')
>>> Path("C:/Users/User/")
WindowsPath('C:/Users/User')
!d pathlib.Path
class pathlib.Path(*pathsegments)```
A subclass of [`PurePath`](https://docs.python.org/3/library/pathlib.html#pathlib.PurePath), this class represents concrete paths of the systemβs path flavour (instantiating it creates either a [`PosixPath`](https://docs.python.org/3/library/pathlib.html#pathlib.PosixPath) or a [`WindowsPath`](https://docs.python.org/3/library/pathlib.html#pathlib.WindowsPath)):
```py
>>> Path('setup.py')
PosixPath('setup.py')
``` *pathsegments* is specified similarly to [`PurePath`](https://docs.python.org/3/library/pathlib.html#pathlib.PurePath).
But none of my friends used any of this
it even has an open method