#off-topic-lounge-text
1 messages ยท Page 34 of 1
good game
jupyter notebook in a docker container or with anaconda all good options
๐คฃ
keep environments isolated
my ide is nice, but I know there are things ppl use to make it easier
^
also path of exile runs on linux
The bat ate the cat.
looping over the list elements :/
you can do that if you use enumerate
can i have voice access? i wanna ask questions but its hard to put it in words
for i, v in enumerate(spam):
print(v * 2) # or print(spam[i] * 2)
prints it x2
!voice
Voice verification
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
I know :^)
add the end='' in the print
what's the problem?
alright
its iterating over the list
^
it does the operation on the current element
and the ~value~ doesn
thanks!
spam = ['cat','bat','rat','elephant'] # content
# loops over the element
for i in spam:
print(i * 2)
# loops over the index
for i in range(len(spam)):
print(i * 2)
its a beginner algo question
when do u need to write "print(list('list'))" and when is print('list') enough ?
!e
print(list('list'))
print('list')
@calm bay :white_check_mark: Your eval job has completed with return code 0.
001 | ['l', 'i', 's', 't']
002 | list
ahhh okay, thx
LX ๐คฃ
what's codejam
this could be a fun one
okay
try doing list slices
bat?
cat only?
[0::2] please
['cat','rat']
with the syntax of this splice, the zero is starting position? and 2 is the every n+2?
call me tread
yeet thanks
replace 1-3
Im not sure :-p
1 first,
2 third,
3 ninth,
spam will return 1 and 3
I only use this for reversing a list!
is the splice the parameter?
only use it!
can you not -1 a list to reverse
!e
foo = [1, 2, 3, 4, 5, 6]
print(foo is foo[::3])
@calm bay slicing does actually create a copy of the list object
@agile portal :white_check_mark: Your eval job has completed with return code 0.
False
the slice is a copy, but the elements are references
what happens if u define an elemnt out of the lists range? like spam[10] = 'test'?
Particularly useful for modifying an out argument.
!e
foo = [1, 2, 3, 4, 5, 6]
print(foo[0] is foo[::3][0])
@calm bay :white_check_mark: Your eval job has completed with return code 0.
True
yep
IndexError
you can use itertools.islice to get an iterator that goes through the elements instead of creating a copy too ๐
kinda useful when looping through a huge slice without modifying
yep, but that's a little advanced for now
ye that was meant for you
shhh
i weirdly like lindex
true = 1
false = 0
I think it is because... everything is on heap and it only stores pointer... it is still a copy!
^
!voice
Voice verification
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
codegolf, I assume this means to arrive at the goal with as little code as possible?
yep!
well, that's one interpretation of it, there's a whole world of what it can actually mean. Usually shortest code is the most common.
*spam removes the brackets and commas and such?
[1][0]
well, * is responsible for unpacking
[1][0]
[1][0]
so
spam = [1,2,3,4]
print(*spam)
# is equivalent to
print(1,2,3,4)
๐
a list inside a list a nested list
๐คฏ
print(spam[1]['20']=
Do any of y'all know project stem by any chance?
which in this case happens to print it out without the [ and ,, but that's not necessarily what * does
yes
lists all the way down........
[0][0]
error#
a character
this is spliception
so "list()" equals adding an [0] ?
wow this is really powerful!
this chat brings the wow factor
i wouldn't be woah-ing without the excitement from these two
What happens... if we stick spam inside of spam?
!e
name1: list = ["I","m","a","i"]
name2: str = "Imai"
print(*name1)
print(*name2)
print(name2)
@leaden drift :white_check_mark: Your eval job has completed with return code 0.
001 | I m a i
002 | I m a i
003 | Imai
typeErr
spam = [0,1,2]
spam[0] = spam
print(spam, spam[0], spam[0][0])
Add a second line spam = [0, spam]
you can't print the end result of the assignment statement within the print statement?
put a star infront of the spam
spam.append(spam)
?
PEMDAS applied here
I hate that it's indexes not indices
were ๐
I don't remember if we can go past negative size in the index.
I don't understand the context, ig
Ah. At least that's safe. Yea.
how do you slice letters out again?
@leaden drift :white_check_mark: Your eval job has completed with return code 0.
['elephant']
we had something like print(spam=spam[0]) or something like that
you cant have the assignment statement within the print statement and they have to be seperated
im saying its inefficient because if order of ops was applied then the assignment statement would execute first then print statement
assignment gives error in print, because it is not a function... and doesn't return anything...
!e print(a = 2)
@icy raven :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: 'a' is an invalid keyword argument for print()
๐ญ
i follow the whole time, i just have my complaints
slice[::-1] โค๏ธ
to the previous message i sent
!e
class OutOfBoundsError(Exception):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
raise OutOfBoundsError("for mustafa")
@calm bay
@agile portal :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | __main__.OutOfBoundsError: for mustafa
thanks for the fun, I have to go.
assignment returning something doesn't make sense... imo, it is pretty consistent!
for pandas slices, it includes the last part
welcome the walrus operator
haha, I forgot about that!
!e
import numpy as np
print(np.__version__)
@shrewd cairn :white_check_mark: Your eval job has completed with return code 0.
1.21.5
apparently bot doesn't have help
spam[0:3] is more like spam [0:3[ xd
it's mathematical notation :p
[0,3)
yep
it still doesn't make sense... and shouldn't have been added...
i find it useful in many situations.
nice one marius (y)
oh no
๐ฆ
!e
spam = ['cat','bat','rat','elephant'] # content
for i in spam:
globals() [i] = i + ' '+ i
print([globals()[i] for i in spam])
@leaden drift :white_check_mark: Your eval job has completed with return code 0.
['cat cat', 'bat bat', 'rat rat', 'elephant elephant']
oh ok
@primal bison
that makes me happy that the walrus operator works ๐
this hurts.
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

๐
it's slow for Data science btw
I know nothing of IT or programming any of that im completely new @fresh sail @calm bay
I heard it was the hardest to learn.
not if you're using pandas/etc well.
yea sure python is slow but most libraries are built in c/c++
Python is the hardest language to learn in program isn't it?
no x)
no
Whats the hardest .-.
c++ prob is more diff
!e
list1, list2 = list1[:] = [[]], []
print(list1)
python
@agile portal :white_check_mark: Your eval job has completed with return code 0.
[[...], []]
python is easiest i think ahaha
hardest ones is Assembly, brainfu*, C++
that deends on the individual person
assembly is possibly the easiest language to learn.
possibly the hardest to do real work with ๐
Ill ask this which is the most desired among employers or industries?
try looking at list methods
when python is hard for yourself but easy for others :'|
yeah
depends on the type of job and specific field
like python xD
.append()
.clear()
.copy()
.count()
.extend()
.index()
.insert()
.pop()
.remove()
.reverse()
.sort()
I thank you gentleman
i tried building a multi-variable find and replace program for my work
i got stuck before they threw out my project
u know that kotlin includes JVM somehow ::p ?
yea it does
so java wins :p
Nah, I will die before java dies in android dev....
what
I was only asking because im between choosing to specialize with AWS or in Network Security but im also wanting to try and learn and stick with programming languages.
scam
Me too!
If that doesn't sound dumb
I agree with you Helium xD
yea
you'll have to be a jack of all trades
Usually employers don't care about languages... if they do, they should stop!
language is just a tool
Fascinating I came in a not knowing anything now im understanding that all branches must be mastered
This is gonna be a interesting route
not mastered
syntax is just a way of communication
Well you get what I mean
you cant master everything
I need a apprenticeship lol
subsurface understanding and experience in many things seems to be more useful than of being a god of one thing
i hate amazon and stand by not learning aws
I just didn't know because the program im going to provides me with an AWS Cert
Is it okay if I post the certification that allow me to earn and recieve after i complete the program?
they*
lol
this is the equivalent of finding out about a copy clipboard
I don't know if any tried but here is the Oracle Cloud Infrastructure
if anyone is trying to learn
https://education.oracle.com/learn/oracle-cloud-infrastructure/pPillar_640/?source=:ow:o:u:nav:::OcomLearnNav&intcmp=:ow:o:u:nav:::OcomLearnNav
lists are mutable therefore append works but tuple isnt (?)
This is a entire different language
this is why python works best because syntactically print and append and copy are very familiar to us, non-programmers, newbies
question before you proceed
high level is translated to assembly then to machine code (binary)
so its good to learn the middle ground (assembly)
a new object with a differnet ID
.-. is there a book i can read
yea learn mips
the parameter you push through spam.clear() will remove everything but or the parameter @calm bay
Mips??? @coarse hollow
im not google
No I was asking if that was the name of the book
b is pointing to spam
When I was learning python... it experiment lead me to whole memory management rabbit hole... and C...
to do an actual copy use deepcopy
I had this issues way to many times ๐ญ
I like to do deep copy with list constructor!
I liked the VS extension
this is similar to java collection pool where some classes would have a .copy() or the keyword new
whats the name of that custom debugger you are using
.
or is that debugger built in to VS
maybe in the future do a lesson on some tkinter or maybe selenium
@unique idol check takumi last message
How can I excess an element of a dict in a list?
concatenation? @calm bay
when would I need to use a dict as opposed to using lists? I have not have a problem thus far using lists tbh
you can append a list
it will append list into list
can you place the list for .extend into a specific place like the beginning as opposed to the end @calm bay
put a * in front of the list inside extend
I'm lazy, even though it's efficient, I can't type extend, I will still use +
Efficient in the sense it creates new list
>>> foo = []
>>> foo.extend((1, 2, 3))
>>> foo
[1, 2, 3]
>>> foo.extend({4, 5, 6})
>>> foo
[1, 2, 3, 4, 5, 6]
>>> foo.extend({7: "something", 8: "something else"})
>>> foo
[1, 2, 3, 4, 5, 6, 7, 8]
also you can use any collection type / iterable to it
surround takumi string with brackets
why foo?
appending is efficient... O(1)...
but efficiency argument doesn't apply to extend... assuming both elements of the list are around same size... it will take O(n) time
common thing for examples so i use it cuz can't be bothered to think of original names
The terms foobar (), foo, bar, baz, and others are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation. They have been used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept.
yeah fair
so adding list to the middle is not that expensive
yes
interesting
fubar*
to know the occurrence number, you can use count()
you can do a loop using the .count(value)
yo what kinda like web stuff can I do with python. I've tried using Selenium but it uses alot of resources and ik u can do it with https requests
spam.index('Takumi', start=6)
but u would need to know the indices?
get all occurrences
indices = [i for i, x in enumerate(spam) if x == "Takumi"]```
positional arguments
whats this in extended syntax?
@calm bay i just found out strings have rindex but lists don't O_o
there is
not without regex
indices = []
for i, x in enumerate(spam):
if x == "Takumi":
indices.append(i)
alr ty
your welcome ๐
or use the .count("value") > 1
I didn't understand takumi ?
oh
I donโt have permission to speak !
!voice
Voice verification
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
that is appending thou
have to have 50 responses and use the voice-verification channel
In any channel I can send ?
for dict, index doesn't matter as much for list (?)
no, I think you have to go to that channel and type the command voiceverify and then follow their instructions
Thank you
๐คฃ
i still havent figured out the voice verification
now can you use slicing in pop
you can use list as a stack... but not perfect! not the most efficient!
hello sir @grave moss , it is an honour to be in the same VC as you. I'm huge fan of your coins.
might be more of an advanced question but what if the list was massive, so you didnt know where "Takumi" was....is there a search function to find "takumi" then find the corresponding index number and pop that out ?
๐ i asked hemlock if he can take a look
you can also try asking in modmail why this might be
regex would be useful
change 3 to your keyword
this sort of stuff doesn't really add anything productive to a conversation.
awesome, thanks!
so its doing type casting on the backend?
i figured it out
what was it? ๐ฎ
help(list.remove)
i was invisible 
!e
spam = ['cat','bat','rat','elephant',"Takumi","Takumi","Takumi","Takumi"] # content
while spam.count('Takumi') > 1:
spam.remove('Takumi')
print(spam)
@leaden drift :white_check_mark: Your eval job has completed with return code 0.
['cat', 'bat', 'rat', 'elephant', 'Takumi']
!e
help(list.remove)
@shrewd cairn :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'help' is not defined
it only works in repl
you can update it in real time
!e
spam = [1, 2, 3]
def custom_reversed(foo):
new_foo = list(foo)
new_foo.reverse()
return new_foo
print(custom_reversed(spam))
@agile portal :white_check_mark: Your eval job has completed with return code 0.
[3, 2, 1]
it will give you an error
saying you passed 1 or more argument while it accepts 0 argument
๐ return foo[::-1]
can u somehow see, where an output or printed text comes from?
!e
list.remove.__doc__
i was just showing how the reversed function actually works (altho it wraps the new list in a iterable object or generator i don't remember which)
this was totally awesome! learning a ton of you all!
iterable ig
๐คฃ
it might be __iter__ getting values from a generator
it works on VS code file but not in python bot
yeah.... I guess, it generates indices as you iterate through elements...
my ears lol
10 mile wind
dude is like on 30000%
hahaha
Hi
@fresh sail try this
spam = ['cat','bat','rat','elephant',"Takumi"]
for i in spam:
globals() [i] = i + ' '+ i
print([globals()[i] for i in spam])
pls no
shhh
don't make me call the mods
I don't like microsoft owning github... that's the only thing, ig...
TOSS A BITCOIN TO YOUR WITCHER!
@icy raven you don't like the in browser vs code ?
and the new dark themes
and the new command pallete on github
Microsoft stole my candy last time
thanks again, I'll try and make Thursday coding session
No, I don't like keeping whole open source community under the mercy of microsoft!
@icy raven you don't like this?
as opposed to a much smaller hosting provider that's more likely to go down?
Let's see... how it goes... it is not about short term...
vs code is great...
I was also joking
what are they going to steal from you?
an api key access to your server
They are doing it with edge again, I heard
@leaden drift they have a program where you can sign up and they help you make sure you don't commit your api keys to github
also i'mma go off now
Almost same
๐คฃ
It is so sneaky... they made it look so similar hoping I won't notice it!
Why do you think they are giving you windows for free @twilit echo
I don't use windows
Okay
I mean they at least improve right ๐คฃ
so I wouldn't really know
Microsoft has every incentive to not screw up... but we will never know what direction they might be heading towards...
if they make ntoskrnl.exe opensource i will start supporting microsoft
anyone else get the "single mom's near you" ad from google ๐ญ
i don't think I've seen an internet ad in years at this point
ublock origin moment
brave hmmmm
can i join the Voice channel before voice verification?
yea u can
why not
def fib(n):
return fib(n - 1) + fib(n - 2)
That's a very inefficient way to implement it. Try running fib(100) on both implementations, you'll find your version takes something around a few thousand years
Hello everyone! I apologize if this is the wrong channel to ask this.
I have a Python application that uses AI (Pytorch and all), and I've successfully made it 100% portable. However, I'm trying to trim the package down and remove all unnecessary files. How would I go about getting a comprehensive list of the files needed to run my application? I've used Pyinstaller to try and figure this out but I'm not trying to turn it in an exe. Any ideas?
also you're missing a base case so this will actually never stop
bruh me just trying to add those colours angrily
ima just check on google
or disc doc
lol
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
yep, i forgot about if n in [0, 1]: check๐
would probably be nicer to do if n < 2:
maybe. opinions are different
From a performance perspective, at least
oof
hi
funny_files 
!code
ello
nope
just little
beginner level
sry?
ahhh its fine
no need to review
@fresh sail ey gl
i cannot speak due to verification. @fresh sail
i will be after 30 messages.
no tbh
im learning python. just im in stage 25 out of 100
im just acknowledging your live stream.
for i, value in enumerate(supplies):
print(i, value)
I always use len for this kinda stuff, maybe there is a better way, idk
for i in range(len(supplies)):
supplies[i] *= 2 # change it to something!
is there a command for scanning a whole array (eq. json ) for a keyword?
doing alot of in operations is not efficient in lists
Hi!
can there be a dic in a set?
(Still working!)
you can have a set in a dictionary as a value but you can't have a dictionary in a set xD
Are the elements in a set still strings?
a = list(range(1000000000))
b = set(range(1000000000))
if something's immutable you can probably put it in a set is easier way to think about it
@fresh sail
could u sum up int in a set faster than in a list?
!e print("" in "something")
@wary lance :white_check_mark: Your eval job has completed with return code 0.
True
How can I check if an element is in a list in a list, if I dont know in which list?
list = ['hi', 'test', ['hai', 'cat']]
a = 'cat' in list # not 'cat' in list[2]
print(a)
@buoyant kestrel pls block Noodle, he's harassing me
you need to write your own function, ig...
You'd just need to loop over it manually
"professionally" no, but I've been using it a while
Don't make me come down there, young man
what happens if u print cat?
isnt the list now a dic?
I know that this isnt a dic but i see some similarities
!e
# this would be an actual input
user_input = "20,30,50"
x, y, z = user_input.split(",")
print(x)
print(y)
print(z)
@fresh sail one usecase which mustafa was talking about in competetions
@agile portal :white_check_mark: Your eval job has completed with return code 0.
001 | 20
002 | 30
003 | 50
1/12 odds
3**4
yeah forgot to put ** in python interpreters
high lvl talk
cry

@calm bay
e.e i don't need to cuz powershell evaluates expressions too
without any extra syntax
i literally always have a python open so no extra effort lol
its 1 extra process
I'm not running windows so it's like 400 less
true
Whats the difference between list.random.shuffle() or random.shuffle(list)?
random is a module in python's standard library and shuffle is a function in that module so you need to import the module and use the function from it
list.random.shuffle() this means, it is a method implemented in list class... (which is not implemented)
random.shuffle(list) this means, random.shuffle is a external function that takes list as input
the list object itself has nothing to randomize
and don't name your list list ๐
Damn i suck more at python than i expected lol
How do I know it is: my_list.sort() and random.shuffle(my_list) and not sort(my_list) or my_list.shuffle?
heya furyoshonen, watcha doing?
Hallo!
I'm interested @calm bay
I would like to see a python3.9 solution to the Knight's tour problem
hey - thanks - I remember having trouble with that one a few years ago.
I'd get on voice chat, but I don't have the requisite 50 messages yet ๐
k is always >= 1 look at constraints @calm bay
ah.. I see
just joined. wassup guys
zeros
increment all zeros outside of loop.. and subtract number of operations
you need to find a better greedy algorithm... @calm bay
Think if you see what numbers they are incrementing in the examples!
that's true
what you said is true
you need to increment small things
see if you can prove it
The knight's tour is to write a program to show how a knight chess piece must move, starting from A1, to every square on a chessboard. I was asked to solve this a few years ago and it stumped me ๐คท
do prod manually @calm bay
and mod
I gotta check, 1 sec
what is a good datastucture to get min in log time! @calm bay
@calm bay it is failing with priority queue... use heapq
it is in queue
put and get methods
@calm bay
priority queue module give some extra safety things...
I saw the code
import heapq
from queue import PriorityQueue
class Solution:
def maximumProduct(self, nums: List[int], k: int) -> int:
heapq.heapify(nums)
mod = 10**9 + 7
pq = PriorityQueue()
pq.queue = nums
for i in range(k):
pq.put(pq.get(nums) + 1)
ans = 1
for i in pq.queue:
ans = (ans * i) % mod
return ans
my hacky thing worked! but it is at the very edge of limit... only worked when taking prod manually!
@buoyant kestrel it is quite nice... name sapces
There's so many things in the standard lib that I've just never seen or knew to even look for
product of such a big list is very big... you should do it manually
NP...
what!!!!!!!!!!
Ah, I see, the way we can move is restricted...
https://www.youtube.com/watch?v=RGQe8waGJ4w
This is quite an interesting video
Featuring Neil Sloane... Check out Brilliant (and get 20% off their premium service): https://brilliant.org/numberphile (sponsor)
More links & stuff in full description below โโโ
Trapped Knight T-Shirt: https://teespring.com/en-GB/numberphile-trapped-knight
Neil Sloane is creator of the On-Line Encyclopedia of Integer Sequences: https://oeis.o...
It's like the fish that got away.
No... it's not me
hehe... yeah
I think I had a problem to traverse a 2-dimensional numpy array in spiral order and return a flattened list.
https://leetcode.com/problems/loud-and-rich/
This was fun
rich is partially ordered set.. first observation!
easier, if you draw the dag @calm bay
I would like it!
is it just a matrix of pixels.. no compression and all?
map we see can be mapped to sphere...
Just project the cylindrical map of height 2r to sphere of radius r
some one will come up ml model of human paint stroke @fresh sail
3 body problem ๐ @calm bay
func_print:
mov rdi, [rsp+8]
mov r9, -3689348814741910323
sub rsp, 40
mov byte [rsp+31], 10
lea rcx, [rsp+30]
mov qword rbx, 0
.L2:
mov rax, rdi
lea r8, [rsp+32]
mul r9
mov rax, rdi
sub r8, rcx
shr rdx, 3
lea rsi, [rdx+rdx*4]
add rsi, rsi
sub rax, rsi
add eax, 48
mov byte [rcx], al
mov rax, rdi
mov rdi, rdx
mov rdx, rcx
sub rcx, 1
cmp rax, 9
ja .L2
lea rax, [rsp+32]
mov edi, 1
sub rdx, rax
xor eax, eax
lea rsi, [rsp+32+rdx]
mov rdx, r8
mov rax, 1
syscall
add rsp, 40
ret
anyone able to help me with some code
HI GUYS HOWDY
hi
class test:
def_init_(self,a='hello world'):
self.a=a
def display(self):
print(self.a)
obj=test()
obj.display()
can anyone help with this?
Damn what's going on guys?
@weak wyvern Susususususus
lol
Still trying to find out where you asked lol.
Join me in this fun interactive session that will help you in exploring Data Analysis and also walk you through the details of the Microsoft Learn Student Ambassador Program.
Key Takeaways:-
-Introduction to Microsoft Learn Student Ambassador
-Overview of what is Data Analysis
-Creating Microsoft Excel Dashboard
-Introduction to Microsoft Power BI
-Quiz and Giveaways
-Q&A
EVENT DETAILS -
Date - 8th May 2022
Day - Sunday
Time - 5:00 PM IST
Duration - 1 Hour
Platform - Microsoft Teams
Event Host - Aditi Gulati (Alpha Microsoft Student Ambassador)
If anyone is interested then DM for registration link
hi everyone
i'm currently working on a fun side project
i'm new to python-- got it working but it's ugly
not optimal
it would be best if i seperated parts into funcitons, but i'm having difficulty going back and compartmentalizing the code i've already written
would anyone like to watch me code live?
Hello mate ๐ i am just ! random noob!
part time/freetime study ๐ I am not that far, only just making calculators! ๐
loops array
today i just smoke and play doom ๐
in no real rush to learn, but 100% sure i learn ๐
i promise i study a few hours tomorrow ๐
Fine i am a noob too
!e
code
!range based for loop
Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.
for i in range(len(my_list)):
do_something(my_list[i])
The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
for item in my_list:
do_something(item)
Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.
@coarse hollow :white_check_mark: Your eval job has completed with return code 0.
001 | H
002 | E
003 | L
004 | L
005 | O
that's A okAy
everyone starts somewhere
code
Hi can someone help me with this simple python problem. I may be overthinking https://stackoverflow.com/questions/72093859/how-do-i-delete-a-particular-sheet-in-a-flat-file-with-python?noredirect=1#comment127383697_72093859
um when will be the dormant channels available
as monk says, u should be using .startswith instead, and it looks like your other issue is that you should be handling deletion one file at a time, so you can make a for loop to loop through each file and delete them one at a time
for file in files:
wb = load_workbook(file)
...
@shell zealot hi thanks for your response. I tried what u said but I think Iโm missing something. Can you please post the answer and I can test it if it works
i don't know what you mean by post the answer, i don't have the solution to whatever exercise you're doing i'm just offering a suggestion for what looks like your current issue?
Could anyone help me with some tkinter code?
!e
a_list = [1, 5, 6, 9, 3, 0]
is_sorted = False
is_changed = False
set_numbers = []
i = 0
k = 1
for i in range(0, (len(a_list) + 1)):
if i != 0:
set_numbers.append(i)
print(set_numbers)
while i < 5:
for j in a_list:
if a_list[i] > a_list[k]:
a_list[i], a_list[k] = a_list[k], a_list[i]
is_changed = True
i += 1
k += 1
else:
is_sorted = True
print(is_changed, is_sorted)
@stiff ice :white_check_mark: Your eval job has completed with return code 0.
001 | [1, 2, 3, 4, 5, 6]
002 | False False
result = sorted(spam2, key = ...)
!e
def a(foo):
foo = [4,5,6]
def b(foo):
foo[:] = [4,5,6]
x = [1,2,3]
a(x)
print(x)
b(x)
print(x)
@calm bay :white_check_mark: Your eval job has completed with return code 0.
001 | [1, 2, 3]
002 | [4, 5, 6]
>>> c = ([0], 1, 2)
>>> c[0] += [69]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> c
([0, 69], 1, 2)
minaberry โ 11/14/2021
so, i think i've read some people say they use this for logging. but otherwise.. it isn't really used anymore, is that right?
Scofflaw โ 11/14/2021
in general its called string interpolation, but python has a bunch of different ways to do string interpolation
minaberry โ 11/14/2021
i'm gonna check my hard copy of this book tmrw bc i don't think i saw this in my copy..
Jack โ 11/14/2021
The logging lib still kind of uses it
I don't recall whether or not the user had to use it though, but it for sure uses it behind the scenes at the very least
godlygeek โ 11/14/2021
The user practically has to use it.
You can do your own string interpolation (using f strings or str.format) but if you do that, you lose some advantages (you pay the formatting cost even for log records that don't ultimately get emitted, and failed interpolation raises an exception instead of just logging an exception)
You can ask logging to instead use str.format() for interpolation, but if you do that you break any third party library that's using % interpolation.
Qwerty โ 11/14/2021
you can choose to use {} formatting
yeah, that's a con
godlygeek โ 11/14/2021
Yeah. That only works if all code in the application agrees to use it, which essentially means that you can't use any third party code.
Or at least, that third party code needs to use a dedicated logger that doesn't propagate to the root logger
minaberry โ 11/14/2021
ok looks like al covers f-strings later in ch 6 https://automatetheboringstuff.com/2e/chapter6/
ooo this is automate the boring stuff audiobook style
@buoyant kestrel just tested the nfc; it works
Niiiiiice
@buoyant kestrel just curious, do you recommend me to shift to discord.py v2.0 when it becomes a stable release?
or should i continue learning discord.js and other stuff?
That's entirely preference. If your stuff is already written in discord.py, then you might as well migrate to 2.0. If you're wanting to learn how to use discord.js or you already are using it, then go with that
I just realized he meant spam like the food, not like spam email
my bots are already in discord.py 2.0.0 [unstable changes everyweek]
but i have also started learning discord.js and typescript...
so i am a bit confused, what should i focus on first?
Well yeah. It's from the Spam skit from Monty Python
Again, it's really up to you, Harsh. If you want to learn discord.js, just go for it
๐
@fresh sail just FYI his first name is "Harsh", it's not an adjective
hujurati
@fresh sail https://en.wikipedia.org/wiki/Gujarati_language
Gujarati (; Gujarati script: เชเซเชเชฐเชพเชคเซ, romanized: Gujarฤtฤซ, pronounced [ษกudสหษพษหtiห]) is an Indo-Aryan language native to the Indian state of Gujarat and spoken predominantly by the Gujarati people. Gujarati is part of the greater Indo-European language family. Gujarati is descended from Old Gujarati (c.โ1100โ1500 CE). In India, it is the officia...
@green trail here
sensei means a teacher
Rust C gcc - Which programs are fastest?
Supp guys
rip
good luck
code
!e
code
!e year = 2000
if (year % 400 == 0) and (year % 100 == 0):
print("{0} is a leap year".format(year))
elif (year % 4 ==0) and (year % 100 != 0):
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
@pseudo latch :white_check_mark: Your eval job has completed with return code 0.
2000 is a leap year
!e year = 2022
if (year % 400 == 0) and (year % 100 == 0):
print("{0} is a leap year".format(year))
elif (year % 4 ==0) and (year % 100 != 0):
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
@pseudo latch :white_check_mark: Your eval job has completed with return code 0.
2022 is not a leap year
!e import time
def countdown(time_sec):
while time_sec:
mins, secs = divmod(time_sec, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
time_sec -= 1
print("stop")
countdown(5)
@pseudo latch :white_check_mark: Your eval job has completed with return code 0.
001 | 00:05
002 | 00:04
003 | 00:03
004 | 00:02
005 | 00:01
006 | stop
!e import time
def countdown(time_sec):
while time_sec:
mins, secs = divmod(time_sec, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
time_sec -= 1
print("stop")
countdown(9999999)
@pseudo latch :x: Your eval job timed out or ran out of memory.
001 | 166666:39
002 | 166666:38
003 | 166666:37
004 | 166666:36
005 | 166666:35
006 | 166666:34
hi
๐
Aliens
https://www.pygame.org/docs/ref/time.html#pygame.time.Clock
https://stackoverflow.com/a/67964799/8346740
Found the thing I was talking about
matrix[(y+dy)%rows][(x+dx)%columns]
color = [int(x*255) for x in color]
Guys can anyone help me?
Guys Iโm in code broccoli if anyone feels like replying to my questions
Thanks for your help
The apple don't want to be eaten ๐
Five dinners? Did you mean 5 dish for dinners? ๐
I guess a dish that costs 5 dinar, which is 9 cents 
@calm bay is that an alpaca doll in your profile picture?
It is
I see..
@calm bay
Wait @buoyant kestrel @unborn sorrel Can you guys let me know quickly how to take out the items in a list to normally print? I forgot
I knew a way then forgot ;-;
Because you can just do print(my_list) but that'll show the brackets. If you want it to just dump out everything and print all that, then you can do print(*my_list) which will unpack it
print it as 3 4 5
Gotcha
yea
The print(*my_list) should work then
Try it and see. Best way to learn is to go hands on
โค๏ธ
my_list = getIntegers(f'{x}')
print(*my_list)``` @buoyant kestrel look at meh
๐
it worked ๐
I can't seem to see the screen....
ah ok
got it
you need to try and have potential if you want to be a helper
@proper cobalt
I don't think you can really try to have potential
like if the staff think your doing great and so in the server they'll do a vote to see if you can become a staff member
That's the whole point of potential
ok im back
Big brain time huh
your indeed right bro
it is time to become big brain
as i am wanting to make something
Mustafa, if you want to add some twists to you snake game, you can make it like pacman but with snake
yo I really need to continue coding my discord bot but I have like negative motivation this is so sad
you making a discord bot?
nice
yeah someone hired me to make one
no, a different one
Can I get some quick advice real quick btw
?
idk if im good at giving advise for this topic
long time no see @buoyant kestrel
im good how are you?
fabulous
โ @carmine kelp can now stream until <t:1651861707:f>.
@buoyant kestrel how hard is it to makea video game with just the code?
oh @buoyant kestrel may i please oh please ask for 32 mins of freedom called sharing my screen on coding?
/python
Is there a twitter list one can follow regarding this server and python in general?
Got it, thank you
!stream @old grove
โ @old grove can now stream until <t:1651862036:f>.
thank you
ok now am i streaming properly?
i believe its working now
now let me see if you can see python
yes, we can see it
pls help ****
@buoyant kestrel I have a quick question
I think im blind and I need a pair of fresh eyes
Can I dm it to you or here?
hamood?
hamood habibi hamood, hamood habibi
@fresh sail this is arabic
@primal bison
it means hammod my love hamood, hamood my love
idk who that is though
Its probably an easy fix but I am tired and have work ina bit
...
while run:
selection = get_option() # Gets the selection from get_option()
if selection == 6:
print("\nYou have exited the program. ")
break
num1 = get_fraction() # Grabs the numbers from get_fraction()
num2 = get_fraction()
result = 0
# What 'if' the user chose of the following selections in main
if selection == 1:
result = add(num1, num2)
elif selection == 2:
result = subtract(num1, num2)
elif selection == 3:
result = multiply(num1, num2)
elif selection == 4:
result = divide(num1, num2)
elif selection == 5:
result = exponent(num1, num2)
ty
ye
i dont like it either but idk waht to change it to
And still make it run
Sorry, take your time but not too much I have to leave in 20 minutes lol.
wait where
I dont see anytrhing
Oh
so put it to the top
And remove run =
So no loop any ways?
okok
but there wouldnt be anything false
unless its not true
what they put
Ohhh
makes sense
Ok good it works now, thankyou so much โค๏ธ
Yea, that was my issue
I was trying to fix it
what could I add?
Also, if the user enters a int like none fraction I dont know what to do to combat that
while run:
selection = get_option() # Gets the selection from get_option()
if selection == 6:
print("\nYou have exited the program. ")
break
elif selection > 6 or selection < 1:
print("Invalid selection.")
continue
Ohhh
but when I type a int
inside my selection it gives error
How can I change it to where if I enter a number it says not a fraction please try again
would i put it in function Fracture?
Yea sorry...
Oh okay.
Wait me
who
Mine? Or yours
Who what?
oh ok
umm
Oh
I thought it would look nicer
And it wasnt working when i did together
Yea kinda
yep
lmk cause imma leave in 10 minutes got work ;-;
like what im doing is going on youtube and finding different videos and trying to make it challenging by adding stuff is that a good way to practice? Or actually do exercises
What u prefer?
Roggen that looks sick!
def get_option():
while True:
selection = input("Make a selection")
try:
selection_number = int(selection)
except ValueError:
print("Invalid entry. Please enter an integer")
continue
if selection_number in range(1, 7):
return selection_number
print("Invalid selection. Please try again")
What does this do now
uhh oine seoncd
Can you explain waht you did real quick
Do we change anything in function main for it?
So its just a cleaner and nicer version of it?
Oh ok
And how about when a user makes a selection, but doesnt enter a fraction and enters a single digit only it causes a error for that I dont know how to fix that part
Ohhhhh
nuu like when they choose they ask for a number
It has to be a fraction
but if they enter a digit
it fails
L.O. ๐
Also, Hemlock, when I enter my fractions it outputs a crazy number over another number... So like how do i fix that without fraction module?
can you check what i sent?
Do you know a quick fix for this
Are you using float.as_integer_ratio?
!paste
Pasting large amounts of code
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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
numerator, denominator = abs(fraction).as_integer_ratio()
what is the pastebin
waht do u wnat me to put?
this?
Essentially it's because the fraction cannot be exactly represented as a float.
hmm... wait waht do i do then to fix it?
hemlock u find anythin?
to fix it quckly?.
i thought he left
!eval ```py
print((0.1).as_integer_ratio())
@cold lintel :white_check_mark: Your eval job has completed with return code 0.
(3602879701896397, 36028797018963968)
You know how, in base 10, 1 / 3 can't be represented exactly (it's 0.3333333....).
The same is true for some numbers in base 2.
Let me take a quick look at the code you've got ๐ค
but i cant do the modulo :.2f
okok
Can you let me know and fix it then if u dont mind real quick
imma leave in 2 minutes ;-;
i dont got time rn lol and I wont be on after work
Erm, short answer is to use fraction.Fraction
You could also use math.gcd to find the greatest common divisor of the numerator and denominator.
You can then divide both by this number to get the fraction in lowest terms.
can you write it for me in that function if u dont mind?
Erm, just a snippet to illustrate the point.
Oh I see ๐ค
So you start with a floating point number, and you need to find the corresponding fraction?
i wanna like output it as a normal fraction
not like 2million ints
so a simplified version
Without using the built in fraction module?
yea is that possible?
It's kind of a tricky problem, because you want to find an approximate fraction with a small numerator and denominator ๐ค
I've just checked and the fraction module itself appears to do the same thing as float.as_integer_ratio
;-;
It gives you the fraction that exactly matches the float.
So how would I do that then?
okie
hemlock u got any ideas? @buoyant kestrel
not really
I have work at 4:30
and i have to go in 3 minutes
Its okay, when I come back ill work on it
no worries
โค๏ธ thankyou ttho guys
Yea for sure
will u be here Hemlock
At like 10?
;-;
oh okay, no worries, enjoy ur weekend man I will figure this out some way or another or just wait till tomorr
but thank you tho
Much love bye!!
Nowadays, the bulk of a compiler is the optimiser.
Which is usually optimising some kind of intermediate representation, like LLVM
Alright I think I've figured out Raif's issue.
The trick is to use decimal, not fractions.
I see a coffee cup ๐
@honest pasture You creepin'?
hi
!eval ```py
from decimal import Decimal
x = 0.1
print(x.as_integer_ratio())
print(round(Decimal(x), 10).as_integer_ratio())
@cold lintel :white_check_mark: Your eval job has completed with return code 0.
001 | (3602879701896397, 36028797018963968)
002 | (1, 10)
@quick onyx 
Like converting floats to fractions like a calculator would.
Yeah, because if you look at what the output of .as_integer_ratio is above, it gives you the fraction that is exactly equal to the float.
Which is some crazy looking fraction ๐
๐
At some point that would have been a major saving!
You don't know how lucky you are sonny boy
I know you're older than me jk
No, I opened the channel once
But
As you noticed
HA
