Last active
December 20, 2018 18:05
-
-
Save Titowisk/e95cb9dec5a3e827c59855fadc8a5f51 to your computer and use it in GitHub Desktop.
Sequencial Error Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
number_of_tries = 1000 | |
number_of_sequencial_errors = 4 | |
error_values = [7,8,9,10] # the condition of unwanted number | |
percentage = (10 - len(error_values))/10 * 100 | |
previous = False # save the previous generated number | |
condition = 0 # verifies when the error happens 3 times | |
count = 0 # counts the number of times the error happens 3 times in a row | |
total = 0 | |
# test_list = [] | |
for n in range(number_of_tries): | |
rolled_number = random.randint(1, 10) | |
# test_list.append(rolled_number) | |
# if previous matches the unwanted values | |
if (rolled_number in error_values): | |
total += 1 | |
condition += 1 | |
else: | |
condition = 0 | |
if condition == 4: | |
count += 1 | |
print(39*"-") | |
print("Percentage: {0}%".format(percentage)) | |
print("Number of times rolled {0}".format(number_of_tries)) | |
print("Number of errors {0} times in a row: {1}".format(number_of_sequencial_errors, count)) | |
print("Number of errors in total: {0}".format(total)) | |
# print("Test: {0}".format(test_list)) | |
print(39*"-") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment