def main():
    # read the file with elements, strip unnecessary pieces of strings, close the file
    file = open("elements.txt", "r")
    element_list = file.readlines()

    for index in range(len(element_list)):
        element_list[index] = element_list[index].strip("\n").lower()

    file.close()

    print("Greetings! It is time to check your knowledge of ATOMIC ELEMENTS.")
    print(
        "Enter any 5 of the first 20 atomic elements from Period Table and I will give you a grade."
    )

    user_input = input("Are you ready (y/n)?\n")

    if user_input.lower() == "y" or user_input.lower() == "yes":
        # get user input collected in a list
        answer_list = get_names()

        # distribute correct and incorrect answers in 2 separate lists
        correct_answers = []
        incorrect_answers = []

        for answer in answer_list:
            if answer in element_list:
                correct_answers.append(answer)
            else:
                incorrect_answers.append(answer)

        # calculate points
        points = calculate_score(correct_answers)

        # print results
        print_results(points, correct_answers, incorrect_answers)
    else:
        print("Sorry to see you go :(")
Exemple #2
0
#print the instructions for a user
print("Greetings! It is time to check your knowledge about ATOMIC ELEMENTS.")
print(
    "Enter any 5 of the first 20 atomic elements from Period Table and I will give you a grade."
)

user_input = input("Are you ready (y/n)?\n")
print("******************************************************************")

if user_input.lower() == "y" or user_input.lower() == "yes":
    # get user input collected in a list
    answer_list = get_names()

    # distribute correct and incorrect answers in 2 separate lists
    correct_answers = []
    incorrect_answers = []

    for answer in answer_list:
        if answer in element_list:
            correct_answers.append(answer)
        else:
            incorrect_answers.append(answer)

    # calculate points
    points = calculate_score(correct_answers)

    # print results
    print_results(points, correct_answers, incorrect_answers)
else:
    print("Sorry to see you go :(")
Exemple #3
0
rmse_test = []
r2_train = []
r2_test = []

for i in range(20):
    # split the data into training and test set
    X_train, X_test, y_train, y_test = train_test_split(X,
                                                        y,
                                                        test_size=0.3,
                                                        random_state=None)

    w = f.ridge_regression(X_train, y_train,
                           0.001)  # compute the best parameter w
    pred_train = f.predictions(X_train,
                               w)  # compute predictions on training set
    pred_test = f.predictions(X_test, w)  # compute predictions on test set

    # results
    r2_train.append(f.r2_score(
        y_train, pred_train))  # compute r2 score for training predictions
    rmse_train.append(f.root_mse(y_train,
                                 pred_train))  # compute training error

    r2_test.append(f.r2_score(
        y_test, pred_test))  # compute r2 score for test predictions
    rmse_test.append(f.root_mse(y_test, pred_test))  # compute test error

# print results
f.print_results(r2_train, r2_test, rmse_train, rmse_test)
plt.show()
Exemple #4
0
print("Scrapper lancé...")

arr_quotes = []  # tableau des citations + auteurs + tags
URL = "https://quotes.toscrape.com"
go_scrapping = True
url = URL

# parcours les pages tant qu'il y a des pages suivantes
while go_scrapping:
    r = requests.get(url)
    soup = BeautifulSoup(r.content, "html.parser")
    arr_quotes = get_quotes(arr_quotes, soup, url)
    page = soup.find("li", attrs={"class": "next"})
    go_scrapping = page is not None
    if go_scrapping:
        link = page.find("a")
        url = URL + link.get('href')

print_quotes(arr_quotes)

print_authors(arr_quotes)

print_tags(arr_quotes)

print_results(arr_quotes)

# affichage des résultats
for q in arr_quotes:
    print(q.content, q.author, q.tags, "\n")
Exemple #5
0
from functions import is_valid, calculate_mark_needed, print_results

# User Inputs
current_mark = raw_input("Enter current mark (%): ")
while is_valid(current_mark) == False:
    current_mark = raw_input("Number not valid.\nEnter current mark (%):")

desired_mark = raw_input("Enter desired mark (%):")
while is_valid(desired_mark) == False:
    desired_mark = raw_input("Number not valid.\nEnter desired mark (%):")

exam_weight = raw_input("Enter exam weight (%):")
while is_valid(exam_weight) == False or exam_weight == '0':
    exam_weight = raw_input("Number not valid.\nEnter exam weight (%):")

# Convert values to floats now that they have been validated
current_mark = float(current_mark)
desired_mark = float(desired_mark)
exam_weight = float(exam_weight)

# Calculate the mark needed
mark_needed = calculate_mark_needed(current_mark, desired_mark,
                                    exam_weight / 100)

# Print results
print_results(mark_needed, desired_mark)
from resolver import find_solution

# MAIN
print("Bienvenue dans ExSy !")

filetext = sys.argv[1:]
if not filetext or len(filetext) > 1:
    print("Erreur Merci de ne passer qu'un seul parametre a ExSy")
    sys.exit(0)


try:
    f = open(filetext[0], 'r')
except IOError:
    print ("Le fichier {0} n'existe pas".format(filetext[0]))
    sys.exit(0)

print("J'analyse votre fichier !")
with open(filetext[0], 'r') as file:
    line = file.readline()
    while line:
        if not read_a_line(line):
            success = 0
            sys.exit(0)
        line = file.readline()
print_results()
print("\n")
find_solution(letter_value, facts_list, conditions_list)
print_results_facts()
# resolve