I had an assignment that required me to perform a task using only modules. I turned in a botched version, but I would actually like to learn how to do it, since it seems important.
Goal: Get numbers from user, add one, display result; all while using modules.
If anyone would be kind enough to walk me through my code, keeping it as close as possible to the original while using modules, that would be appreciated.
Goal: Get numbers from user, add one, display result; all while using modules.
# Enter numbers and store them as "enterNumbers()" module? def enterNumbers(): float(input("Type numbers: ")) return # This "calculate" module calls the "enterNumbers()" module, adds 1, and returns "a" which basically means "a" in the module IS "calculate()?" def calculate(): a = enterNumbers() + 1 return a # This "main()" module calls both module to calculate? def main(): enterNumbers() calculate() return # This runs all of the modules? main()My code seems to duplicate "enter numbers" twice. I'm pretty sure it's because I have "enterNumbers" in the "calculate()" module, as well as the "main()" module. To me, it seems like "a" is defining "enterNumbers() + 1", so I'm not trying to call it, only use it's stored data. Also, i feel like I'm missing something in the () of one of the modules to make it work right, I just can't figure out what.
If anyone would be kind enough to walk me through my code, keeping it as close as possible to the original while using modules, that would be appreciated.