#π HW Help CS200
84 messages Β· Page 1 of 1 (latest)
@neat violet
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.
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
!rule homework
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
What is the problem, then?
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.
#problem 18
#input sphere volune
#output radius of the sphere
def volume_to_radius(v):
pass
def side_max_square(v):
pass
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.
what do you mean?
Do you know the math equations required to perform these operaitons?
I just dont want to enter the whole pdf of problems to show the example thats all
When you convert math formulas to Python, remember that:
3xor(4)(a + b)will not do multiplication. you have to use*every time you want to multiply.- The operator for exponents is
**
I get that im just not sure how to input sphere volume and output the radius
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
forgetting Python for a moment, how would you calculate the radius given the volume?
(purely a mathematical question at this point)
something has to be 3d to have volume.
but its volume
so then you know which of circle or sphere etrotta was talking about.
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
yea it tells you so at the bottom of the pdf you showed
The sketch is not asking anything, it's just visualizing the problem for you. π
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)
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.
Curious: why the round(s,2) at the end?
to round the integer so I dont have a long number for autograder
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 π€
Usually we would not put that in the function itelf, as you want to return the most precise result possible. Instead, that's a "display" problem: maybe round it when you print it out, if you're printing it.
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.
Ok then. Must have missed that requirement.
It says on my assignment to use round to the hundredths using the round() function
let me see what I get on the autograder first
ok so it worked
which is great
cool
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 = (((t2) + (20 * t) + 100))
content = 100 * (num/denom)
return content
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.
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
Looks ok, except for the missing rounding?
Does the autograder show you what it expected? Or just says "no"?
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
I was just thinking that iif it had shown you "I expected 12.32" the problem might have been more apparent..
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
math.ceil rounds up.
import math
........
rounded_up = math.ceil(9.1) # should get 10
ohhh
Looks like they want math.ceil instead of round (which would round-nearest).
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)
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.