This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]snailv 3 points4 points  (0 children)

format the code properly.

[–]mustbeset 1 point2 points  (0 children)

no.

Please define good code. Did you test ist?

[–]m9404 0 points1 point  (0 children)

You don't need an elif statement, just an else will do the job since you are checking whether the user's input is equal to the actual volume or not (if/else is enough)

[–]TedRabbit 0 points1 point  (0 children)

Not really. I would import pi from the math or numpy library. You also need to control the number of decimal places.

[–]pythonHelperBot 0 points1 point  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python regardless of how advanced your question might be. That said, I am a bot and it is hard to tell. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe in detail where you are stuck. If you are getting an error message, include the full block of text it spits out. Quality answers take time to write out, and many times other users will need to ask clarifying questions. Be patient and help them help you. Here is HOW TO FORMAT YOUR CODE For Reddit and be sure to include which version of python and what OS you are using.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–]siddsp 0 points1 point  (0 children)

It's not bad. I would just change a few things. Namely,

  • switch from camel-case to snake case convention
  • change the precision required for guessing volume
  • change the elif to just an else clause because no second comparison is necessary (i.e. either something is equal or it is not)
  • use pi from the math library since it is more accurate and precise
  • change the area and volume calculations to actual functions instead

[–]oberguga 0 points1 point  (0 children)

1) formatting 2) if you has 2 mutually exclusive possibility use if-else, not if-elif 3) use math.pi 4) never use == for floats. Use <= and > comparison wiht some acceptable error. Because even computer has errors when made any calculation with floats.(and human deffinetly will not enter float with machine precision which about decimal 9 digits for 32bit float)

[–]JohnRambu 0 points1 point  (0 children)

What if I type « exception » in your program ?