#Guys lil help plz!

70 messages · Page 1 of 1 (latest)

tall ice
#

i cant get the common divisors part right, pls help...

short cairn
#

a & b doesn't do what you think it does

tall ice
#

so how would i do it then? yea output theres an error there its supposed to be print(a2 & b2)

short cairn
#

unless you think it does bitwise AND operation, but then I'm not sure that's useful in this program

tall ice
#

i just need the output to print similar numbers from a & b divisors

calm mauve
#

How are you learning python?

tall ice
#

uhh i dont know what u mean srry, in school i guess

short cairn
#

do you have tutorials or reference materials from school? or are you just writing what you think the code should look like?

calm mauve
#

I'm only asking because it seems like the resources you're using may be misleading or outdated

tall ice
#

I'm just doing it from previous methods, I know there's a more optional way but I'm bad

#

And I missed class for this part but i have to do it at home

short cairn
#

were you ever introduced to the & operator? it's very uncommon to use in python

tall ice
#

Yea I used it some times

short cairn
#

to do what?

tall ice
#

For conditions

calm mauve
#

That

#

s strange

tall ice
#

Multiple conditions

short cairn
#

& is not a conditional operator, it takes two numbers and returns a third

calm mauve
#

Are you thinking that & and and are the same?

tall ice
#

Yea

calm mauve
#

Because as christopher said, in python they're different

short cairn
#

but also, print(a and b) would probably not display what I think you want here

tall ice
#

Yea error there

#

ohh ok i got it now

#

wait nvm

#

its not giving me the right common divisors

#

after changing & to and

calm mauve
#

At the moment your code has too many issues that fixing one still leaves a lot

#

Could you give us your overall goal for this code?

#

Each thing it's supposed to achieve

tall ice
#
  1. Find all the divisors of a
  2. Find all the divisors of b
  3. Find all the common divisors between a and b
  4. Find the highest values from the common divisors between a and b
#

a and b is input

#

i got 1-2 good tho juast 3 & 4 left

calm mauve
#

Okay steps 1 and 2 are fine

#

but wouldn't it be smarted to somehow store what you find in 1 and 2

#

so that you can use them in 3 and 4?

tall ice
#

how do i do that?

#

c=a2 and b2?

#

lel

rigid sun
#

you'd want two lists, one for the divisors of a, another for the divisors of b

calm mauve
#

Think about all the ways you know how to store values

tall ice
#

c=a2

#

lemme check

#

thats howd i d store it ig

#

nope thats wrong

calm mauve
#

Have you heard of lists? tuples? sets? dictionaries? etc?

tall ice
#

lists and sets i think

#

i just cant remember how you do it, i usually have to refer to stuff ive done

calm mauve
#

Maybe it's time to learn then 😊

tall ice
#

ohh i got it

#

u use thiss [a,b]

#

ok i got it

#

idk let me know if theres a better way to do this ig...

#

had a 2month break, coding just slips out easily

calm mauve
#

Did you test the code?

tall ice
#

yea

#

got what i wanted

calm mauve
#

I doubt the code works

#

It looks wrong to me

tall ice
#

wait rlly?

calm mauve
#

Yes

tall ice
calm mauve
#

6 is not a common divisor of 3 and 6

tall ice
#

fudge

#

sec

calm mauve
tall ice
#

c[a==b] gives boolean result instead...

tall ice
#

omg finally