I have two python files:
- Term
- Today
In all the py files the user is to enter some data For instance in the term.py file the user is to enter the age and the duration. How can I make today.py file have access to the data variables(age and duration) which have been input by the user in the in the term.py file
In the term.py file I have this code
def Term_advance():
print('advance')
n = int(input('enter duration (n) :'))
age = int(input("enter life's age :"))
Sum_assuared = int(input('enter sum assuared :'))
basis = input('what is the calculation basis::\n'
'1.\t AM 92\n'
'2.\t ELT 15 MALES\n'
'3.\t ELT 12 FELAMES\n'
'4.\t PEN\n'
'5.\t A1967-70\n')
If basis==1:
today.tables_advance_perpetuity()
Then in the today.py file I have this code which reads the values from an excel document, the values however are to be input by the user in the Term.py file
import xlrd
loc = "C:PycharmProjects/Life annuities/tables.xlsx"
wb = xlrd.open_workbook(loc)
def tables_advance_perpetuity():
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)
num = int(input('enter the age of the life:'))
for i in range(sheet.nrows):
x = sheet.cell_value(i, 0)
if x == num:
dx = sheet.cell_value(num - 1, 2)
nx = sheet.cell_value(num - 1, 6)
print(dx)
print(nx)
ann = nx / dx
print(f'Annuity value is {ann}')
So like for this case how can the today file read for instance the age of the life entered by the user in the term.py file( instead of asking the user to enter the values again in the today.py file)