I'm having trouble writing a simple Python program for a beginner programming class. If someone could look at the code I currently have and guide me in the right direction it would be much appreciated! Here is the code:
def main():
print 'Welcome to the PACU nurse to patient program'
print
patients = inputPatients()
nurses = getNurses(patients)
nurseAssistants = getAssistants(nurses)
printInfo = (patients, nurses, nurseAssistants)
raw_input()
def inputPatients():
patients = input('Enter the number of patients for this shift (up to 40): ')
return patients
def getNurses(patients):
nurses = (1.0 / 3.0) * patients
return nurses
def getAssistants(nurses):
nurseAssistants = (1.0 / 2.0) * nurses
return nurseAssistants
def printInfo(patients, nurses, nurseAssistants):
print 'The number of patients for this shift is:', patients
print 'The number of nurses needed is:', nurses
print 'The number of nurses Assistants is:', nurseAssistants
main()
Change the last segment of code to:
def printInfo(patients, nurses, nurseAssistants):
print 'The number of patients for this shift is:', patients
print 'The number of nurses needed is:', nurses
print 'The number of nurses Assistants is:', nurseAssistants
main()
Since python executes based on indentation. Also, remove the = from the printInfo statement and make it:
nurses = getNurses(patients)
nurseAssistants = getAssistants(nurses)
printInfo(patients, nurses, nurseAssistants)
Previous answers have hinted at the main problem but not explained why you are not seeing any output.
The following assigns a tuple containing the 3 values for patients, nurses, and nurse assistants to the variable named printInfo.
printInfo = (patients, nurses, nurseAssistants)
It does not produce any output and it does not call the function printInfo() as you are probably expecting. What you actually need is to make a function call:
printInfo(patients, nurses, nurseAssistants)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With