#off-topic-lounge-text

1 messages ยท Page 34 of 1

leaden drift
#

or you could do it in vscode Jupiter

proven basalt
#

good game

covert summit
#

jupyter notebook in a docker container or with anaconda all good options

leaden drift
#

๐Ÿคฃ

covert summit
#

keep environments isolated

proven basalt
#

my ide is nice, but I know there are things ppl use to make it easier

leaden drift
#

^

proven basalt
#

also path of exile runs on linux

covert summit
#

The bat ate the cat.

leaden drift
#

looping over the list elements :/

covert summit
#

you can do that if you use enumerate

leaden drift
#
for i in range(len(spam)):
  print(spam[i]
#

is another way

golden ingot
#

can i have voice access? i wanna ask questions but its hard to put it in words

covert summit
#
for i, v in enumerate(spam):
  print(v * 2) # or print(spam[i] * 2)
leaden drift
#

prints it x2

timid fjordBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

covert summit
#

I know :^)

leaden drift
#

add the end='' in the print

golden ingot
#

what's the problem?

leaden drift
#

alright

golden ingot
#

its iterating over the list

sly beacon
#

cat, cat, ...

#

yea

golden ingot
#

^

unique idol
#

yeah

#

or wouldnt it be cat, rat?

#

ahhh

leaden drift
golden ingot
#

and the ~value~ doesn

unique idol
#

thanks!

golden ingot
#

doesnt have to be int

#

we can do a leetcode question

leaden drift
#
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)
golden ingot
#

its a beginner algo question

sly beacon
#

when do u need to write "print(list('list'))" and when is print('list') enough ?

calm bay
#

!e

print(list('list'))
print('list')
timid fjordBOT
#

@calm bay :white_check_mark: Your eval job has completed with return code 0.

001 | ['l', 'i', 's', 't']
002 | list
sly beacon
#

ahhh okay, thx

leaden drift
#

LX ๐Ÿคฃ

icy raven
#

what's codejam

golden ingot
#

this could be a fun one

icy raven
#

okay

leaden drift
#

try doing list slices

golden ingot
#

bat?

cerulean storm
#

cat only?

leaden drift
#

๐Ÿคฃ

#

๐Ÿ™‚

calm bay
#

[0::2] please

cerulean storm
#

['cat','rat']

leaden drift
#

^

#

try using the list methods

golden ingot
#

with the syntax of this splice, the zero is starting position? and 2 is the every n+2?

#

call me tread

#

yeet thanks

leaden drift
#

you would get a error

#

so best to put in a try and except block

sly beacon
#

replace 1-3

unique idol
#

Im not sure :-p

crimson sparrow
#

1 first,
2 third,
3 ninth,

golden ingot
#

spam will return 1 and 3

crimson sparrow
#

I was closest to right

#

lol

#

I'm learning something ๐Ÿ˜„

icy raven
#

I only use this for reversing a list!

golden ingot
#

is the splice the parameter?

icy raven
crimson sparrow
#

can you not -1 a list to reverse

agile portal
#

!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

timid fjordBOT
#

@agile portal :white_check_mark: Your eval job has completed with return code 0.

False
calm bay
#

the slice is a copy, but the elements are references

sly beacon
#

what happens if u define an elemnt out of the lists range? like spam[10] = 'test'?

wary lance
#

Particularly useful for modifying an out argument.

calm bay
#

!e

foo = [1, 2, 3, 4, 5, 6]
print(foo[0] is foo[::3][0])
timid fjordBOT
#

@calm bay :white_check_mark: Your eval job has completed with return code 0.

True
agile portal
#

yep

leaden drift
#

IndexError

agile portal
#

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

calm bay
#

yep, but that's a little advanced for now

agile portal
#

ye that was meant for you

leaden drift
#

shhh

agile portal
#

i weirdly like lindex

crimson sparrow
#

true = 1
false = 0

icy raven
leaden drift
#

^

golden ingot
#

!voice

timid fjordBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

crimson sparrow
#

codegolf, I assume this means to arrive at the goal with as little code as possible?

calm bay
#

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.

golden ingot
#

*spam removes the brackets and commas and such?

cerulean storm
#

[1][0]

calm bay
#

well, * is responsible for unpacking

leaden drift
#

[1][0]

golden ingot
#

[1][0]

calm bay
#

so

spam = [1,2,3,4]
print(*spam)

# is equivalent to

print(1,2,3,4)
golden ingot
#

๐Ÿ˜„

leaden drift
#

a list inside a list a nested list
๐Ÿคฏ

sly beacon
#

print(spam[1]['20']=

primal bison
#

Do any of y'all know project stem by any chance?

calm bay
#

which in this case happens to print it out without the [ and ,, but that's not necessarily what * does

leaden drift
#

yes

icy raven
#

lists all the way down........

leaden drift
#

[0][0]

sly beacon
#

error#

leaden drift
#

a character

golden ingot
#

this is spliception

sly beacon
#

so "list()" equals adding an [0] ?

unique idol
#

wow this is really powerful!

golden ingot
#

this chat brings the wow factor

#

i wouldn't be woah-ing without the excitement from these two

wary lance
#

What happens... if we stick spam inside of spam?

leaden drift
#

!e

name1: list = ["I","m","a","i"]
name2: str = "Imai"
print(*name1)
print(*name2)
print(name2)
timid fjordBOT
#

@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
leaden drift
#

typeErr

calm bay
#
spam = [0,1,2]
spam[0] = spam
print(spam, spam[0], spam[0][0])
wary lance
#

Add a second line spam = [0, spam]

golden ingot
#

you can't print the end result of the assignment statement within the print statement?

leaden drift
#

put a star infront of the spam

icy raven
#

spam.append(spam)

golden ingot
#

i recognize that

#

seems inefficient

#

can't use order of operation

icy raven
golden ingot
calm bay
#

I hate that it's indexes not indices

leaden drift
#

were ๐Ÿ‘

wary lance
#

I don't remember if we can go past negative size in the index.

icy raven
wary lance
#

Ah. At least that's safe. Yea.

leaden drift
#

!e

spam = ['cat','bat','rat','elephant'] # content

print(spam[::-19])
#

nvm :\

crimson sparrow
#

how do you slice letters out again?

timid fjordBOT
#

@leaden drift :white_check_mark: Your eval job has completed with return code 0.

['elephant']
golden ingot
# icy raven I don't understand the context, ig

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

shrewd cairn
#

hey everyone ๐Ÿ‘‹

#

if you put -1 in step you will reverse the list

icy raven
shrewd cairn
#

I am good

#

thx xD

icy raven
#

!e print(a = 2)

timid fjordBOT
#

@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()
leaden drift
#

๐ŸŽญ

golden ingot
shrewd cairn
#

slice[::-1] โค๏ธ

golden ingot
#

to the previous message i sent

agile portal
#

!e

class OutOfBoundsError(Exception):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

raise OutOfBoundsError("for mustafa")

@calm bay

timid fjordBOT
#

@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
crimson sparrow
#

thanks for the fun, I have to go.

icy raven
shrewd cairn
#

for pandas slices, it includes the last part

agile portal
#

!e

print(help(slice))
#

D:

icy raven
shrewd cairn
#

!e

import numpy as np
print(np.__version__)
timid fjordBOT
#

@shrewd cairn :white_check_mark: Your eval job has completed with return code 0.

1.21.5
agile portal
#

apparently bot doesn't have help

sly beacon
#

spam[0:3] is more like spam [0:3[ xd

shrewd cairn
#

it's mathematical notation :p

calm bay
#

[0,3)

shrewd cairn
#

yep

icy raven
calm bay
shrewd cairn
#

nice one marius (y)

leaden drift
#

oh no

calm bay
#
if x := func():
  print(x)
#
x = func()
if x:
  print(x)
shrewd cairn
#

I loved it

#

does it reduce the time complexity ?

golden ingot
#

๐Ÿ˜ฆ

leaden drift
#

!e

spam = ['cat','bat','rat','elephant'] # content

for i in spam:
    globals() [i] = i + ' '+ i
print([globals()[i] for i in spam])
timid fjordBOT
#

@leaden drift :white_check_mark: Your eval job has completed with return code 0.

['cat cat', 'bat bat', 'rat rat', 'elephant elephant']
shrewd cairn
#

oh ok

fresh sail
#

@primal bison

golden ingot
#

that makes me happy that the walrus operator works ๐Ÿ™‚

icy raven
golden ingot
leaden drift
shrewd cairn
#

it's slow for Data science btw

primal bison
#

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.

calm bay
leaden drift
primal bison
#

Python is the hardest language to learn in program isn't it?

shrewd cairn
#

no x)

golden ingot
#

no

primal bison
#

Whats the hardest .-.

unique idol
#

c++ prob is more diff

agile portal
#

!e

list1, list2 = list1[:] = [[]], []
print(list1)
leaden drift
timid fjordBOT
#

@agile portal :white_check_mark: Your eval job has completed with return code 0.

[[...], []]
cerulean storm
#

python is easiest i think ahaha

shrewd cairn
#

hardest ones is Assembly, brainfu*, C++

calm bay
calm bay
#

possibly the hardest to do real work with ๐Ÿ™‚

primal bison
#

Ill ask this which is the most desired among employers or industries?

leaden drift
#

try looking at list methods

golden ingot
#

when python is hard for yourself but easy for others :'|

shrewd cairn
#

yeah

unique idol
shrewd cairn
#

like python xD

leaden drift
#

.append()
.clear()
.copy()
.count()
.extend()
.index()
.insert()
.pop()
.remove()
.reverse()
.sort()

primal bison
#

I thank you gentleman

golden ingot
#

i tried building a multi-variable find and replace program for my work

#

i got stuck before they threw out my project

leaden drift
#

kotlin is a thing now

#

it's pretty powerful

shrewd cairn
#

u know that kotlin includes JVM somehow ::p ?

leaden drift
shrewd cairn
#

so java wins :p

icy raven
#

Nah, I will die before java dies in android dev....

leaden drift
#

what

primal bison
#

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.

leaden drift
#

scam

icy raven
#

Me too!

primal bison
#

If that doesn't sound dumb

shrewd cairn
#

I agree with you Helium xD

leaden drift
#

yea

golden ingot
icy raven
#

Usually employers don't care about languages... if they do, they should stop!

shrewd cairn
#

language is just a tool

primal bison
#

Fascinating I came in a not knowing anything now im understanding that all branches must be mastered

#

This is gonna be a interesting route

golden ingot
#

not mastered

shrewd cairn
#

syntax is just a way of communication

primal bison
#

Well you get what I mean

golden ingot
#

you cant master everything

primal bison
#

I need a apprenticeship lol

golden ingot
#

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

primal bison
#

I just didn't know because the program im going to provides me with an AWS Cert

leaden drift
#

yes

#

sure

primal bison
#

Is it okay if I post the certification that allow me to earn and recieve after i complete the program?

#

they*

golden ingot
#

WITCH

#

thats fucking wild

unique idol
#

lol

golden ingot
#

this is the equivalent of finding out about a copy clipboard

leaden drift
golden ingot
#

lists are mutable therefore append works but tuple isnt (?)

primal bison
#

This is a entire different language

golden ingot
#

this is why python works best because syntactically print and append and copy are very familiar to us, non-programmers, newbies

primal bison
#

Im not a noob

#

Im a scrub

golden ingot
#

question before you proceed

coarse hollow
#

high level is translated to assembly then to machine code (binary)

#

so its good to learn the middle ground (assembly)

leaden drift
#

a new object with a differnet ID

primal bison
#

.-. is there a book i can read

coarse hollow
#

yea learn mips

golden ingot
#

the parameter you push through spam.clear() will remove everything but or the parameter @calm bay

primal bison
#

Mips??? @coarse hollow

coarse hollow
#

im not google

primal bison
#

No I was asking if that was the name of the book

shrewd cairn
#

b is pointing to spam

icy raven
#

When I was learning python... it experiment lead me to whole memory management rabbit hole... and C...

shrewd cairn
#

to do an actual copy use deepcopy

leaden drift
#

I had this issues way to many times ๐Ÿ˜ญ

icy raven
#

I like to do deep copy with list constructor!

shrewd cairn
#

I liked the VS extension

leaden drift
#

this is similar to java collection pool where some classes would have a .copy() or the keyword new

unique idol
#

whats the name of that custom debugger you are using

leaden drift
#

.

unique idol
#

or is that debugger built in to VS

golden ingot
#

maybe in the future do a lesson on some tkinter or maybe selenium

#

@unique idol check takumi last message

sly beacon
#

How can I excess an element of a dict in a list?

golden ingot
#

how about count anything but 10?

#

like !=

icy raven
#

it's :q, you're welcome ๐Ÿ™ƒ @calm bay

#

i'm kidding

golden ingot
#

concatenation? @calm bay

primal bison
#

when would I need to use a dict as opposed to using lists? I have not have a problem thus far using lists tbh

leaden drift
#

you can append a list

icy raven
#

it will append list into list

golden ingot
#

can you place the list for .extend into a specific place like the beginning as opposed to the end @calm bay

leaden drift
#

put a * in front of the list inside extend

icy raven
#

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

agile portal
#
>>> 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

shrewd cairn
#

surround takumi string with brackets

icy raven
#

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

agile portal
#

common thing for examples so i use it cuz can't be bothered to think of original names

calm bay
# primal bison why foo?

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.

primal bison
#

yeah fair

icy raven
shrewd cairn
#

yes

primal bison
agile portal
shrewd cairn
#

to know the occurrence number, you can use count()

leaden drift
#

you can do a loop using the .count(value)

primal bison
#

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

calm bay
#
spam.index('Takumi', start=6)
golden ingot
shrewd cairn
#

get all occurrences


indices = [i for i, x in enumerate(spam) if x == "Takumi"]```
leaden drift
#

positional arguments

primal bison
agile portal
#

@calm bay i just found out strings have rindex but lists don't O_o

golden ingot
#

there is

agile portal
golden ingot
#

u can use regular expressions

#

true

shrewd cairn
shrewd cairn
#

your welcome ๐Ÿ˜„

leaden drift
shrewd cairn
#

I didn't understand takumi ?

leaden drift
#

oh

fallen nexus
#

I donโ€™t have permission to speak !

golden ingot
#

!voice

timid fjordBOT
#

Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

leaden drift
#

that is appending thou

unique idol
icy raven
#

front is not efficient @calm bay

#

yeah

fallen nexus
golden ingot
#

for dict, index doesn't matter as much for list (?)

unique idol
leaden drift
#

๐Ÿคฃ

golden ingot
#

i still havent figured out the voice verification

agile portal
#

you are verified @golden ingot you just need to unmute

#

to talk

leaden drift
#

now can you use slicing in pop

icy raven
#

you can use list as a stack... but not perfect! not the most efficient!

primal bison
#

hello sir @grave moss , it is an honour to be in the same VC as you. I'm huge fan of your coins.

unique idol
#

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 ?

agile portal
# golden ingot

๐Ÿ‘€ i asked hemlock if he can take a look
you can also try asking in modmail why this might be

calm bay
#

this sort of stuff doesn't really add anything productive to a conversation.

unique idol
#

so its doing type casting on the backend?

agile portal
#

what was it? ๐Ÿ˜ฎ

calm bay
#
help(list.remove)
golden ingot
leaden drift
#

!e

spam = ['cat','bat','rat','elephant',"Takumi","Takumi","Takumi","Takumi"] # content

while spam.count('Takumi') > 1:
    spam.remove('Takumi')
print(spam)
timid fjordBOT
#

@leaden drift :white_check_mark: Your eval job has completed with return code 0.

['cat', 'bat', 'rat', 'elephant', 'Takumi']
shrewd cairn
#

!e

help(list.remove)
timid fjordBOT
#

@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
icy raven
leaden drift
#

you can update it in real time

calm bay
#

reversed()

#

reversed(spam)

agile portal
#

!e

spam = [1, 2, 3]

def custom_reversed(foo):
   new_foo = list(foo)
   new_foo.reverse()
   return new_foo

print(custom_reversed(spam))
timid fjordBOT
#

@agile portal :white_check_mark: Your eval job has completed with return code 0.

[3, 2, 1]
leaden drift
#

it will give you an error

#

saying you passed 1 or more argument while it accepts 0 argument

sly beacon
#

can u somehow see, where an output or printed text comes from?

shrewd cairn
#

!e

list.remove.__doc__
agile portal
leaden drift
#

click the x in the corner

#

the terminal

unique idol
#

this was totally awesome! learning a ton of you all!

leaden drift
#

๐Ÿคฃ

agile portal
leaden drift
agile portal
shrewd cairn
icy raven
unique idol
#

my ears lol

leaden drift
#

10 mile wind

sly beacon
#

dude is like on 30000%

agile portal
#

try and turn on krisp noise supression

#

in your settings

#

@formal falcon

unique idol
#

hahaha

primal bison
#

Hi

leaden drift
#

@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])
leaden drift
calm bay
#

don't make me call the mods

leaden drift
#

oh no

#

๐Ÿ˜ญ

icy raven
#

I don't like microsoft owning github... that's the only thing, ig...

#

TOSS A BITCOIN TO YOUR WITCHER!

agile portal
#

@icy raven you don't like the in browser vs code ?

#

and the new dark themes

#

and the new command pallete on github

leaden drift
#

Microsoft stole my candy last time

unique idol
#

thanks again, I'll try and make Thursday coding session

icy raven
#

No, I don't like keeping whole open source community under the mercy of microsoft!

agile portal
#

@icy raven you don't like this?

calm bay
icy raven
#

Let's see... how it goes... it is not about short term...

#

vs code is great...

#

I was also joking

leaden drift
#

what are they going to steal from you?
an api key access to your server

icy raven
#

They are doing it with edge again, I heard

agile portal
#

@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

icy raven
#

Almost same

leaden drift
#

๐Ÿคฃ

icy raven
#

It is so sneaky... they made it look so similar hoping I won't notice it!

leaden drift
#

they do

#

yes they do

icy raven
#

Why do you think they are giving you windows for free @twilit echo

calm bay
#

I don't use windows

icy raven
#

Okay

leaden drift
#

I mean they at least improve right ๐Ÿคฃ

calm bay
#

so I wouldn't really know

icy raven
#

Microsoft has every incentive to not screw up... but we will never know what direction they might be heading towards...

sinful salmon
#

if they make ntoskrnl.exe opensource i will start supporting microsoft

leaden drift
#

anyone else get the "single mom's near you" ad from google ๐Ÿ˜ญ

calm bay
#

i don't think I've seen an internet ad in years at this point

sinful salmon
calm bay
#

nope, i just have brave

#

it's built in

sinful salmon
#

brave hmmmm

charred rain
#

can i join the Voice channel before voice verification?

candid anvil
#

yea u can

charred rain
#

ok, so I will be just muted until the verification?

#

very deep

#

cute kitten

leaden drift
ashen geode
calm bay
minor lion
#

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?

agile portal
primal bison
#
print("sup")
primal bison
#

ima just check on google

#

or disc doc

#

lol

timid fjordBOT
#

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.

ashen geode
calm bay
ashen geode
#

maybe. opinions are different

calm bay
#

From a performance perspective, at least

primal bison
#

oof

strange steeple
#

hi

cold lintel
#

funny_files pithink

austere hazel
#

!code

cerulean storm
#

ello

#

nope

#

just little
beginner level

#

sry?

#

ahhh its fine

#

no need to review

autumn kayak
#

@fresh sail ey gl

untold vapor
#

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.

icy raven
#

No, continue!

#

haha

calm bay
#
for i, value in enumerate(supplies):
  print(i, value)
icy raven
#

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!
sly beacon
#

is there a command for scanning a whole array (eq. json ) for a keyword?

icy raven
#

doing alot of in operations is not efficient in lists

wary lance
#

Hi!

sly beacon
#

can there be a dic in a set?

wary lance
#

(Still working!)

agile portal
#

you can have a set in a dictionary as a value but you can't have a dictionary in a set xD

sly beacon
#

Are the elements in a set still strings?

icy raven
#
a = list(range(1000000000))
b = set(range(1000000000))
agile portal
#

if something's immutable you can probably put it in a set is easier way to think about it

icy raven
#

@fresh sail

sly beacon
#

could u sum up int in a set faster than in a list?

icy raven
#

OOPS

#

haha

wary lance
#

!e print("" in "something")

timid fjordBOT
#

@wary lance :white_check_mark: Your eval job has completed with return code 0.

True
icy raven
#

haha

#

sorry about that!

sly beacon
#

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)
calm bay
#

@buoyant kestrel pls block Noodle, he's harassing me

fresh sail
icy raven
calm bay
primal bison
calm bay
#

"professionally" no, but I've been using it a while

buoyant kestrel
#

Don't make me come down there, young man

sly beacon
#

what happens if u print cat?

#

isnt the list now a dic?

#

I know that this isnt a dic but i see some similarities

agile portal
#

!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

timid fjordBOT
#

@agile portal :white_check_mark: Your eval job has completed with return code 0.

001 | 20
002 | 30
003 | 50
calm bay
icy raven
#

1/12 odds

calm bay
#

3**4

deft bloom
#

so advanced stuff

#

hard

icy raven
deft bloom
#

high lvl talk

sly beacon
deft bloom
agile portal
#

@calm bay
e.e i don't need to cuz powershell evaluates expressions too

#

without any extra syntax

calm bay
#

i literally always have a python open so no extra effort lol

agile portal
#

its 1 extra process

calm bay
#

I'm not running windows so it's like 400 less

agile portal
#

true

sly beacon
#

Whats the difference between list.random.shuffle() or random.shuffle(list)?

agile portal
#

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

icy raven
#

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

agile portal
#

the list object itself has nothing to randomize

icy raven
primal bison
#

Damn i suck more at python than i expected lol

sly beacon
icy raven
#

you just lookup

#

if it is useful, your brain will remember it for you!

coral lily
#

heya furyoshonen, watcha doing?

fresh sail
errant mountain
#

Hallo!

icy raven
#

I'm interested @calm bay

errant mountain
#

I would like to see a python3.9 solution to the Knight's tour problem

icy raven
#

1 sec

#

@calm bay

errant mountain
#

hey - thanks - I remember having trouble with that one a few years ago.

errant mountain
#

I'd get on voice chat, but I don't have the requisite 50 messages yet ๐Ÿ˜„

charred rain
#

i completed it yesterday :0

#

*:)

icy raven
#

k is always >= 1 look at constraints @calm bay

charred rain
#

enjoy coding!

#

i'm going

icy raven
#

ah.. I see

steep pond
#

just joined. wassup guys

icy raven
#

@calm bay it is better to do outside of loops...

#

@calm bay int div

icy raven
#

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

errant mountain
#

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 ๐Ÿคท

icy raven
#

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

icy raven
#

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

buoyant kestrel
#

There's so many things in the standard lib that I've just never seen or knew to even look for

icy raven
#

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...

โ–ถ Play video
errant mountain
#

It's like the fish that got away.

icy raven
#

No... it's not me

errant mountain
#

hehe... yeah

icy raven
#

haha...

#

pull that np card!

calm bay
errant mountain
#

I think I had a problem to traverse a 2-dimensional numpy array in spiral order and return a flattened list.

icy raven
#

rich is partially ordered set.. first observation!

#

easier, if you draw the dag @calm bay

agile portal
#

@wide aurora mustafa's working on the raytracer

#

wanna join?

#

๐Ÿ™‚

icy raven
#

I would like it!

calm bay
icy raven
#

is it just a matrix of pixels.. no compression and all?

calm bay
icy raven
#

cool

#

Going for dinner... will be back in 10 min

calm bay
icy raven
#

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

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
zenith flicker
#

anyone able to help me with some code

magic grove
#

HI GUYS HOWDY

primal bison
#

hi

pale dust
#

hi

#

do you guys have any Ideas?

#

(I don't know game should I make now)

rocky folio
open swift
#

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?

steep pond
#

Damn what's going on guys?

mortal depot
#

@weak wyvern Susususususus

weak wyvern
#

lol

mortal depot
primal bison
#

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

tawny thicket
noble thistle
#

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?

worthy token
#

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 ๐Ÿ˜„

magic grove
heady yacht
#

!e

timid fjordBOT
#
Missing required argument

code

coarse hollow
#

!range based for loop

timid fjordBOT
#

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
#

i really dont know python lol

#

!e

x = "HELLO"
for i in x:
  print(i)
timid fjordBOT
#

@coarse hollow :white_check_mark: Your eval job has completed with return code 0.

001 | H
002 | E
003 | L
004 | L
005 | O
golden ingot
haughty dagger
timid fjordBOT
#
Missing required argument

code

primal bison
#

coding

#

Ood

#

ooof

#

?;:ยงbqsdf

tribal prism
#
delicate egret
#

um when will be the dormant channels available

shell zealot
tribal prism
#

@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

shell zealot
#

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?

summer sigil
#

Could anyone help me with some tkinter code?

stiff ice
#

!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)
timid fjordBOT
#

@stiff ice :white_check_mark: Your eval job has completed with return code 0.

001 | [1, 2, 3, 4, 5, 6]
002 | False False
stiff ice
#

why does this not work

#

it should return true

calm bay
#
result = sorted(spam2, key = ...)
calm bay
#

!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)
timid fjordBOT
#

@calm bay :white_check_mark: Your eval job has completed with return code 0.

001 | [1, 2, 3]
002 | [4, 5, 6]
calm bay
#
>>> 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)
shadow ivy
#

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

tender tangle
#

@buoyant kestrel just tested the nfc; it works

buoyant kestrel
#

Niiiiiice

steady hare
#

@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?

fresh sail
buoyant kestrel
#

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

calm bay
#

I just realized he meant spam like the food, not like spam email

steady hare
buoyant kestrel
#

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

steady hare
#

๐Ÿ‘

calm bay
#

@fresh sail just FYI his first name is "Harsh", it's not an adjective

steady hare
#

hujurati

tender tangle
#

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...

steady hare
#

will you guys stay after 1hr?

#

cause i need to study chemistry

tender tangle
#

I'll be eating supper then

#

it'll be half past 7

steady hare
#

ah ic

#

it's 10pm in india

#

so late : /

#

bye bye

fresh sail
#

@green trail here

green trail
#

hello bro

#

hello there are you talking to me

left locust
#

sensei means a teacher

carmine current
buoyant kestrel
buoyant kestrel
primal bison
#

Supp guys

agile portal
#

well

#

i yanked my headset's wire out

#

and it is not working anymore....

calm bay
#

rip

agile portal
#

but it works on my mobile

#

i will try the good old restart windows brb

calm bay
#

good luck

light panther
#

nordi c= + 9 ter ( { p[ent

#

verbose=-10

timid fjordBOT
#
Missing required argument

code

pseudo latch
#

!e

timid fjordBOT
#
Missing required argument

code

pseudo latch
#

!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))

timid fjordBOT
#

@pseudo latch :white_check_mark: Your eval job has completed with return code 0.

2000 is a leap year
pseudo latch
#

!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))

timid fjordBOT
#

@pseudo latch :white_check_mark: Your eval job has completed with return code 0.

2022 is not a leap year
pseudo latch
#

!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)

timid fjordBOT
#

@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
pseudo latch
#

!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)

timid fjordBOT
#

@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
hasty flicker
#

hi

light panther
#

001

sturdy parcel
#

ho do I comnd the computer if I press w botton move up

#

how **

buoyant kestrel
cold lintel
#

๐ŸŽ‰

buoyant kestrel
#

Aliens

buoyant kestrel
fresh sail
calm bay
#

matrix[(y+dy)%rows][(x+dx)%columns]

calm bay
#
color = [int(x*255) for x in color]
cerulean stirrup
#

Guys can anyone help me?

calm bay
cerulean stirrup
#

Guys Iโ€™m in code broccoli if anyone feels like replying to my questions

#

Thanks for your help

dense prawn
#

I am gonna watch that

#

xD

slim wave
#

The apple don't want to be eaten ๐Ÿ˜‚

cold lintel
#

I'll accept five dinners ๐Ÿ˜‹

#

Nooo VCO ๐Ÿ˜”

#

That sucks lol

slim wave
cold lintel
#

I guess a dish that costs 5 dinar, which is 9 cents lemon_pensive

slim wave
#

@calm bay is that an alpaca doll in your profile picture?

buoyant kestrel
#

It is

slim wave
#

I see..

unborn sorrel
#

@calm bay

quick onyx
#

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 ;-;

buoyant kestrel
#

As in grabbing one by the index?

#

Or just to print them all

quick onyx
#

print them all out

#

but not the list

#

so if its lioke [3, 4. 5]

buoyant kestrel
#

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

quick onyx
#

print it as 3 4 5

buoyant kestrel
#

Gotcha

quick onyx
#

yea

buoyant kestrel
#

The print(*my_list) should work then

quick onyx
#

print(getIntegers(f'{x}'))

#

this is my line rn

#

so just implement it?

buoyant kestrel
#

Try it and see. Best way to learn is to go hands on

quick onyx
#

โค๏ธ

primal bison
#

how to

#

lambdaemon

quick onyx
#
my_list = getIntegers(f'{x}')
print(*my_list)``` @buoyant kestrel look at meh
#

๐Ÿ˜„

#

it worked ๐Ÿ™‚

primal bison
#

how to stream

#

no perms

slim wave
#

role

#

:)

old grove
#

im here now

#

@calm bay can i ask how you managed to stream on python since i cant

ivory cloak
#

I can't seem to see the screen....

old grove
#

ah ok

#

got it

#

you need to try and have potential if you want to be a helper

#

@proper cobalt

ivory cloak
#

I don't think you can really try to have potential

old grove
#

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

ivory cloak
old grove
#

ok im back

ivory cloak
#

Big brain time huh

old grove
#

it is time to become big brain

#

as i am wanting to make something

ivory cloak
#

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

ivory cloak
old grove
#

uh...

#

was this in the server

ivory cloak
old grove
#

ah ok good

#

alright 1st bit is done

ivory cloak
old grove
#

idk if im good at giving advise for this topic

#

long time no see @buoyant kestrel

#

im good how are you?

#

fabulous

calm bay
buoyant kestrel
#

!stream 169457879336747008

timid fjordBOT
#

โœ… @carmine kelp can now stream until <t:1651861707:f>.

old grove
#

@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

strange wraith
#

Is there a twitter list one can follow regarding this server and python in general?

#

Got it, thank you

buoyant kestrel
#

!stream @old grove

timid fjordBOT
#

โœ… @old grove can now stream until <t:1651862036:f>.

old grove
#

thank you

#

ok now am i streaming properly?

#

i believe its working now

#

now let me see if you can see python

snow orchid
#

yes, we can see it

primal bison
#

pls help ****

calm bay
old grove
#

im back

#

ah ok

quick onyx
#

@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?

fresh sail
#

hamood?
hamood habibi hamood, hamood habibi

old grove
#

@fresh sail this is arabic

buoyant kestrel
#

@primal bison

old grove
#

it means hammod my love hamood, hamood my love

quick onyx
#

I sent you it Hemmy

#

Okay, sorry.

old grove
#

idk who that is though

quick onyx
#

Its probably an easy fix but I am tired and have work ina bit

old grove
#

...

quick onyx
#

ye sorry lol.

#

So which line?

#

Which function

buoyant kestrel
#
    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)
quick onyx
#

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

buoyant kestrel
#
    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
quick onyx
#

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!

buoyant kestrel
#
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")
quick onyx
#

What does this do now

buoyant kestrel
#

Which part has you confused?

#

Or do you need me to break it out step by step

quick onyx
#

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

cold lintel
#

L.O. ๐Ÿ‘‹

quick onyx
#

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

cold lintel
#

Are you using float.as_integer_ratio?

quick onyx
#

;-;

#

rip

#

uhhh

#

yea

#

I think

#

yea

buoyant kestrel
#

!paste

timid fjordBOT
#

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.

quick onyx
#

numerator, denominator = abs(fraction).as_integer_ratio()

#

what is the pastebin

#

waht do u wnat me to put?

#

this?

cold lintel
#

Essentially it's because the fraction cannot be exactly represented as a float.

quick onyx
#

hmm... wait waht do i do then to fix it?

#

hemlock u find anythin?

#

to fix it quckly?.

#

i thought he left

cold lintel
#

!eval ```py
print((0.1).as_integer_ratio())

timid fjordBOT
#

@cold lintel :white_check_mark: Your eval job has completed with return code 0.

(3602879701896397, 36028797018963968)
quick onyx
#

oh woah

#

so what can I do to fix that? Instead of 20 million numbers lol.

cold lintel
#

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 ๐Ÿค”

quick onyx
#

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

cold lintel
#

Erm, short answer is to use fraction.Fraction

quick onyx
#

but i dont want to use fraction module ;-;

#

is there another way?

cold lintel
#

You could also use math.gcd to find the greatest common divisor of the numerator and denominator.

quick onyx
#

hmmm

#

How would i implement that tho?

cold lintel
#

You can then divide both by this number to get the fraction in lowest terms.

quick onyx
#

can you write it for me in that function if u dont mind?

cold lintel
#

Erm, just a snippet to illustrate the point.

quick onyx
#

uhh

#

but where i put it in?

#

here?

#

do i have to change the whole function?

#

lol

cold lintel
#

Oh I see ๐Ÿค”

#

So you start with a floating point number, and you need to find the corresponding fraction?

quick onyx
#

i wanna like output it as a normal fraction

#

not like 2million ints

#

so a simplified version

buoyant kestrel
#

Without using the built in fraction module?

quick onyx
#

yea is that possible?

buoyant kestrel
#

Yeah, just confirming

#

Wonder how the fraction module actually does it...

quick onyx
#

idk

#

how long will it be then?

cold lintel
#

It's kind of a tricky problem, because you want to find an approximate fraction with a small numerator and denominator ๐Ÿค”

quick onyx
#

yea ;-;

#

how would the fraction module work tho if we used that?

cold lintel
#

I've just checked and the fraction module itself appears to do the same thing as float.as_integer_ratio

quick onyx
#

;-;

cold lintel
#

It gives you the fraction that exactly matches the float.

quick onyx
#

So how would I do that then?

cold lintel
#

Erm, I'm not entirely sure

#

I'd have to think about it.

quick onyx
#

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!!

cold lintel
#

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 ๐Ÿ‘€

buoyant kestrel
#

@honest pasture You creepin'?

hazy harbor
#

hi

cold lintel
#

!eval ```py
from decimal import Decimal
x = 0.1
print(x.as_integer_ratio())
print(round(Decimal(x), 10).as_integer_ratio())

timid fjordBOT
#

@cold lintel :white_check_mark: Your eval job has completed with return code 0.

001 | (3602879701896397, 36028797018963968)
002 | (1, 10)
cold lintel
#

@quick onyx jam_cuneiform_this

#

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

honest pasture
#

But

#

As you noticed

vernal snow
honest pasture
#

I may as well post what made me open it

#

The pinnacle of Reddit posts

buoyant kestrel
#

HA