I am trying to make a datalogging code, for the user to input the number and age of animals, the birth rate and their chances of surviving the generation. I have tried to use return but when I run the program, the variables remain at 0.
Here I have initiated the variables
Gen0_J=0
Gen0_A=0
Gen0_S=0
Birth_rate=0
Srate_J=0
Srate_A=0
Srate_S=0
New_generations=5
My first function
def generation_values():
Gen0_J=int(input("How many juveniles in Generation 0? "))
Gen0_A=int(input("How many adults in Generation 0? "))
Gen0_S=int(input("How many seniles in Generation 0? "))
Srate_J=float(input("What is the survival rate for juveniles? "))
Srate_A=float(input("What is the survival rate for adults? "))
Srate_S=float(input("What is the survival rate for seniles? "))
Birth_rate=int(input("What is the birth rate? "))
return Gen0_J,Gen0_A,Gen0_S,Srate_J,Srate_A,Srate_S,Birth_rate
displaying the variables
def display_values():
print("\nThe amount of juveniles in Generation 0 is",Gen0_J)
print("The amount of adults in Generation 0 is",Gen0_A)
print("The amount of seniles in Generation 0 is",Gen0_S)
print("The birth rate in Generation 0 is",Birth_rate)
print("The survival rate for juveniles in Generation 0 is",Srate_J)
print("The survival rate for adults in Generation 0 is",Srate_A)
print("The survival rate for seniles in Generation 0 is",Srate_S)
generation_values()
display_values()
However, the variables stay at 0
How many juveniles in Generation 0? 5
How many adults in Generation 0? 6
How many seniles in Generation 0? 7
What is the survival rate for juveniles? 0.75
What is the survival rate for adults? 1
What is the survival rate for seniles? 0
What is the birth rate? 2
The amount of juveniles in Generation 0 is 0
The amount of adults in Generation 0 is 0
The amount of seniles in Generation 0 is 0
The birth rate in Generation 0 is 0
The survival rate for juveniles in Generation 0 is 0
The survival rate for adults in Generation 0 is 0
The survival rate for seniles in Generation 0 is 0