Is it possible to use only part of the input from the user and neglect the parts where there is no input given?
Say I want to calculate the used volume of a cylinder filled with a liquid. I would ask the user for input, for example the volume of the cylinder is given together with the height of the cylinder, than the program should be able to return the diameter of the cylinder, the circumference, the surface area, ...
Say that the user can only provide the diameter and the fill percentage, the program should be able to return the same things as previous.
I tried to ask for input as follows:
volume = float(input("volume in qubic meters: ") or None
diameter = float(input("tankdiameter: ") or None
# etc...
Then I would write a class:
class object:
__init__(volume, diameter, heigth, fill_percentage, radius, circumference, surface_area,...)
self.volume = volume
# etc...
Next there will be functions in the class to calculate the not provided items for instance if height and diameter are given, it calculates the volume. But I'm getting stuck with the input of the user. Eventually it's the idea that there comes a GUI where the input fields are being linked to the code.
Any suggestions?
or Noneshould accomplish?foo = input("type something: ") or "default"assigns"default"if the user doesn't type anything.class object:it will overwrite the python baseobjectclass which is the last thing anyone would want :)float(input("volume in qubic meters: ") or Noneandfloat(input("tankdiameter: ") or Noneare not syntactically valid as they're missing closing parenthesis). It's not clear if this is where you're "getting stuck with the input of the user" since you haven't said what you exactly mean by "getting stuck" or shared any error messages/stack traces as part of a minimal reproducible example.