import sys
import numpy as np
from functions import *
print("|",format("\033[1;36m Welcome to Bacteria Analyzing \033[0m","*^60"),"|")
print("\n Please select the action you want to take:")
print("\n 1. Load data")
print("\n 2. Filter data")
print("\n 3. Diaplay statistics")
print("\n 4. Generate plots")
print("\n 5. Quit")
user_option=int(input("The action you want to take: "))
data = np.loadtxt("valid_data.txt")
def filter_data():
global bacteria
bacteria=int(input("What kind of bacteria you want to analise? (Type in NA if you don't want to filter bacteria) "))
global groRate_l
groRate_l=float(input("lower limit: "))
global groRate_h
groRate_h=float(input("higner limit: "))
print(("The bacteria you want to check is""\033[1;35m {0}\033[0m").format(bacteria))
print(("The growth range you want to check is ""\033[1;35m[{:f},{:f}]\033[0m").format(groRate_l,groRate_h))
global data_f
data_f=data[((data[:,1]>groRate_l) & (data[:,1]<groRate_h) & (data[:,2]==bacteria))]
if user_option==1:
try:
file_name=str(input("Pease enter your file's name: "))
dataLoad(file_name)
except:
print("\033[1;31m File not found, plesae check your spelling.\033[0m")
if user_option==2:
filter_data()
if user_option==3:
statistic = str(input("which statistic you want to perform? "))
dataStatistics(data_f, statistic)
if user_option==5:
print("Thank you for using, bye~")
sys.exit()
还有怎么样定义一个全局变量: