#πŸ”’ HW Help CS200

84 messages Β· Page 1 of 1 (latest)

neat violet
#

Need help with a set of problems for college. I have 20 problems I need to do and not sure what to do for the ones Im getting errors on and the ones I havent done. If any coders could dm help that would be great. NO CHAT GPT

lilac hillBOT
#

@neat violet

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

neat violet
#

I have done 13 out of 20 already but some have errors

#

if anybody would be willing to shoot me a dm that would be great

waxen totem
#

!rule homework

lilac hillBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

neat violet
#

not doing it for me just help Im confused

#

help is allowed

keen snow
#

What is the problem, then?

waxen totem
#

Also

  • No DMs. Ask your questions in this channel ; if you cannot share it publicly, don't share it with strangers at all
  • We have our own rules against ChatGPT usage, if you see someone violating it let mods know. No need to state it in your question.
tulip sky
#

i think that its best to not say anything

#

not trying to be rude

neat violet
#

#problem 18
#input sphere volune
#output radius of the sphere
def volume_to_radius(v):
pass

def side_max_square(v):
pass

lilac hillBOT
#

Hey @neat violet!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
waxen totem
neat violet
waxen totem
neat violet
#

I just dont want to enter the whole pdf of problems to show the example thats all

urban crater
#

When you convert math formulas to Python, remember that:

  • 3x or (4)(a + b) will not do multiplication. you have to use * every time you want to multiply.
  • The operator for exponents is **
neat violet
waxen totem
#

for square root, you can use math.sqrt or ** 0.5 (as in, exp to the power of 1/2)

for pi, you should use math.pi unless they say to use some other constant value

waxen totem
#

(purely a mathematical question at this point)

neat violet
#

you mean of a sphere?

#

or a circle

#

pi r^2 for radius

urban crater
#

something has to be 3d to have volume.

neat violet
#

but its volume

urban crater
#

so then you know which of circle or sphere etrotta was talking about.

neat violet
#

should I put the equation in for volume like volume = (4*3) * math.pi * (r**2)

#

and then return round (volume, 2) to get it rounded

#

im not sure what its asking by giving a sketch

glass cipher
#

yea it tells you so at the bottom of the pdf you showed

covert kayak
neat violet
#

got it

#

I think I got it

#

def volume_to_radius(v):
r = (((v / (4/3)) / math.pi) ** (1/3))
return round(r, 2)

def side_max_square(v):
s = (volume_to_radius(v) * 2) / math.sqrt(3)
return round(s,2)

lilac hillBOT
#

Hey @neat violet!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
lapis cliff
#

Curious: why the round(s,2) at the end?

neat violet
#

to round the integer so I dont have a long number for autograder

covert kayak
#

I don't see an example value for v that could be used to test with, is there some other part that gives you that value?

#

Though I guess one could work backwards from the radius 8 πŸ€”

lapis cliff
covert kayak
#

The problem does state they should round the returned value.
Homework problems will often do this to normalize the responses so they know what they have is accurate.

lapis cliff
#

Ok then. Must have missed that requirement.

neat violet
#

let me see what I get on the autograder first

#

ok so it worked

#

which is great

glass cipher
#

cool

neat violet
#

theres one more which isnt working though

#

I have this for code

#

Problem 2

#input t days
#output oxygen conten percent of it normal level
def f(t):
num = (((t2) + (10 * t) + 100))
denom = (((t
2) + (20 * t) + 100))
content = 100 * (num/denom)
return content

lilac hillBOT
#

Hey @neat violet!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
neat violet
#

shoot hold on

#
# Problem 2
#input t days
#output oxygen conten percent of it normal level
def f(t):
    num  = (((t**2) + (10 * t) + 100))
    denom = (((t**2) + (20 * t) + 100))
    content = 100 * (num/denom)
    return content
lapis cliff
#

Looks ok, except for the missing rounding?

neat violet
#

might be let me check

#

yeah that was it

lapis cliff
#

Does the autograder show you what it expected? Or just says "no"?

neat violet
#

it's supposed to show you what you got wrong but it doesnt output any code

#

so it kinda just says youre right or youre wrong

lapis cliff
#

I was just thinking that iif it had shown you "I expected 12.32" the problem might have been more apparent..

neat violet
#

wdym

#

oh like the output

#

this is what it shows

#

you mean like that

#

because for this one

#

# Problem 6
#input number of susceptible, but healthy children
#output number of the infected children
# use math.ceil() before returning your final answer.
def I(S):
    outbreak = (192 * math.log2(S /762) - S + 763)
    return round(outbreak)
#

im not sure how to use math.ciel() in it

lapis cliff
#

math.ceil rounds up.

neat violet
#

it rounds up no matter what

#

?

lapis cliff
#
import math
........
rounded_up = math.ceil(9.1) # should get 10
neat violet
#

ohhh

lapis cliff
#

Looks like they want math.ceil instead of round (which would round-nearest).

neat violet
#

how would I use it with a return function

#
import math
def I(S):
    outbreak = (192 * math.log2(S /762) - S + 763)
    return math.ceil(outbreak)
lilac hillBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.