I have two python files:
- Term
- Today
In the term.py file, the user is to enter some data For instance, in the term.py file, the user is to enter the age,sum_assuared, and the duration. How can I make today.py file have access to the data variables(age,sum_assuared and duration) which have been input by the user in the term.py file instead of asking them to input the variables again in the today.py file
In the term.py file, I have this code
import today
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 that reads the values from an excel document. The variables here, however, are to already input by the user in the Term.py file(age,n, and sum_assuared)
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,sum_assuared and n 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)
Like I seek to be able to read the variables(age,sum_assuared, and n) which are in the term.py file.So I wish to access them using the today.py file. instead of having a second prompt asking for the values in the today.py file