From 546c44eebd846246a1e3bf1789ac696a7da7d592 Mon Sep 17 00:00:00 2001 From: huqi Date: Sat, 23 Jan 2021 23:47:58 +0800 Subject: [PATCH 1/3] pip --- Pipfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Pipfile diff --git a/Pipfile b/Pipfile new file mode 100644 index 00000000000..22d660a0251 --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.8" From 95d3dc4e06bbbfaeb5f60e59318ea5216ac84c77 Mon Sep 17 00:00:00 2001 From: huqi Date: Sat, 23 Jan 2021 23:53:23 +0800 Subject: [PATCH 2/3] choose Upper --- AREA OF TRIANGLE | 17 ------ Area of triangle | 13 ----- ...ogram to Remove Punctuations From a String | 16 ------ ...ogram to Remove Punctuations from a String | 18 ------ Random Password Generator | 12 ---- random password generator | 57 ------------------- 6 files changed, 133 deletions(-) delete mode 100644 AREA OF TRIANGLE delete mode 100644 Area of triangle delete mode 100644 Python Program to Remove Punctuations From a String delete mode 100644 Python Program to Remove Punctuations from a String delete mode 100644 Random Password Generator delete mode 100644 random password generator diff --git a/AREA OF TRIANGLE b/AREA OF TRIANGLE deleted file mode 100644 index e71116f9762..00000000000 --- a/AREA OF TRIANGLE +++ /dev/null @@ -1,17 +0,0 @@ -# Python Program to find the area of triangle -#calculates area of traingle in efficient way!! -a = 5 -b = 6 -c = 7 - -# Uncomment below to take inputs from the user -# a = float(input('Enter first side: ')) -# b = float(input('Enter second side: ')) -# c = float(input('Enter third side: ')) - -# calculate the semi-perimeter -s = (a + b + c) / 2 - -# calculate the area -area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 -print('The area of the triangle is %0.2f' %area) diff --git a/Area of triangle b/Area of triangle deleted file mode 100644 index d2da3975289..00000000000 --- a/Area of triangle +++ /dev/null @@ -1,13 +0,0 @@ -a = 5 -b = 6 -c = 7 -# a = float(input('Enter first side: ')) -# b = float(input('Enter second side: ')) -# c = float(input('Enter third side: ')) - -# calculate the semi-perimeter -s = (a + b + c) / 2 - -# calculate the area -area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 -print('The area of the triangle is %0.2f' %area) diff --git a/Python Program to Remove Punctuations From a String b/Python Program to Remove Punctuations From a String deleted file mode 100644 index a1e750a3a4b..00000000000 --- a/Python Program to Remove Punctuations From a String +++ /dev/null @@ -1,16 +0,0 @@ -# define punctuation -punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' - -my_str = "Hello!!!, he said ---and went." - -# To take input from the user -# my_str = input("Enter a string: ") - -# remove punctuation from the string -no_punct = "" -for char in my_str: - if char not in punctuations: - no_punct = no_punct + char - -# display the unpunctuated string -print(no_punct) diff --git a/Python Program to Remove Punctuations from a String b/Python Program to Remove Punctuations from a String deleted file mode 100644 index 16ace54c672..00000000000 --- a/Python Program to Remove Punctuations from a String +++ /dev/null @@ -1,18 +0,0 @@ -punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' - -my_str = "Hello!!!, he said ---and went." - -no_punct = "" -patch-2 -for char in my_str: - if char not in punctuations: - no_punct = no_punct + char - -for char in my_str: - -if char not in punctuations: - -no_punct = no_punct + char - -master -print(no_punct) diff --git a/Random Password Generator b/Random Password Generator deleted file mode 100644 index b13262dadf8..00000000000 --- a/Random Password Generator +++ /dev/null @@ -1,12 +0,0 @@ -import random - -low="abcdefghijklmnopqrstuvwxyz" -upp="ABCDEFGHIJKLMNOPQRSTUVWXYZ" -num="0123456789" -sym="!@#$%^&*" - -all=low+upp+num+sym -length=8 -password="".join(random.sample(all,length)) -print(password) - diff --git a/random password generator b/random password generator deleted file mode 100644 index 33f86c1c4b1..00000000000 --- a/random password generator +++ /dev/null @@ -1,57 +0,0 @@ -import random - -LOWERCASE_CHARS = tuple(map(chr, xrange(ord('a'), ord('z')+1))) -UPPERCASE_CHARS = tuple(map(chr, xrange(ord('A'), ord('Z')+1))) -DIGITS = tuple(map(str, range(0, 10))) -SPECIALS = ('!', '@', '#', '$', '%', '^', '&', '*') - -SEQUENCE = (LOWERCASE_CHARS, - UPPERCASE_CHARS, - DIGITS, - SPECIALS, - ) - -def generate_random_password(total, sequences): - r = _generate_random_number_for_each_sequence(total, len(sequences)) - - password = [] - for (population, k) in zip(sequences, r): - n = 0 - while n < k: - position = random.randint(0, len(population)-1) - password += population[position] - n += 1 - random.shuffle(password) - - while _is_repeating(password): - random.shuffle(password) - - return ''.join(password) - -def _generate_random_number_for_each_sequence(total, sequence_number): - """ Generate random sequence with numbers (greater than 0). - The number of items equals to 'sequence_number' and - the total number of items equals to 'total' - """ - current_total = 0 - r = [] - for n in range(sequence_number-1, 0, -1): - current = random.randint(1, total - current_total - n) - current_total += current - r.append(current) - r.append(total - sum(r)) - random.shuffle(r) - - return r - -def _is_repeating(password): - """ Check if there is any 2 characters repeating consecutively """ - n = 1 - while n < len(password): - if password[n] == password[n-1]: - return True - n += 1 - return False - -if __name__ == '__main__': - print generate_random_password(random.randint(6, 30), SEQUENCE) From 51aff991da8be8584fe7b69b2890a60b88e8eecd Mon Sep 17 00:00:00 2001 From: huqi Date: Sun, 24 Jan 2021 00:00:55 +0800 Subject: [PATCH 3/3] Fix clone error --- AREA OF TRIANGLE1.py | 17 ++++++ AREA OF TRIANGLE2.py | 13 +++++ ...m to Remove Punctuations From a String1.py | 16 ++++++ ...m to Remove Punctuations From a String2.py | 18 ++++++ Random Password Generator1.py | 11 ++++ Random Password Generator2.py | 57 +++++++++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 AREA OF TRIANGLE1.py create mode 100644 AREA OF TRIANGLE2.py create mode 100644 Python Program to Remove Punctuations From a String1.py create mode 100644 Python Program to Remove Punctuations From a String2.py create mode 100644 Random Password Generator1.py create mode 100644 Random Password Generator2.py diff --git a/AREA OF TRIANGLE1.py b/AREA OF TRIANGLE1.py new file mode 100644 index 00000000000..76acd962e9f --- /dev/null +++ b/AREA OF TRIANGLE1.py @@ -0,0 +1,17 @@ +# Python Program to find the area of triangle +#calculates area of traingle in efficient way!! +a = 5 +b = 6 +c = 7 + +# Uncomment below to take inputs from the user +# a = float(input('Enter first side: ')) +# b = float(input('Enter second side: ')) +# c = float(input('Enter third side: ')) + +# calculate the semi-perimeter +s = (a + b + c) / 2 + +# calculate the area +area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 +print('The area of the triangle is %0.2f' %area) \ No newline at end of file diff --git a/AREA OF TRIANGLE2.py b/AREA OF TRIANGLE2.py new file mode 100644 index 00000000000..9e8386ed4fd --- /dev/null +++ b/AREA OF TRIANGLE2.py @@ -0,0 +1,13 @@ +a = 5 +b = 6 +c = 7 +# a = float(input('Enter first side: ')) +# b = float(input('Enter second side: ')) +# c = float(input('Enter third side: ')) + +# calculate the semi-perimeter +s = (a + b + c) / 2 + +# calculate the area +area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 +print('The area of the triangle is %0.2f' %area) \ No newline at end of file diff --git a/Python Program to Remove Punctuations From a String1.py b/Python Program to Remove Punctuations From a String1.py new file mode 100644 index 00000000000..e30a3b90e1a --- /dev/null +++ b/Python Program to Remove Punctuations From a String1.py @@ -0,0 +1,16 @@ +# define punctuation +punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' + +my_str = "Hello!!!, he said ---and went." + +# To take input from the user +# my_str = input("Enter a string: ") + +# remove punctuation from the string +no_punct = "" +for char in my_str: + if char not in punctuations: + no_punct = no_punct + char + +# display the unpunctuated string +print(no_punct) \ No newline at end of file diff --git a/Python Program to Remove Punctuations From a String2.py b/Python Program to Remove Punctuations From a String2.py new file mode 100644 index 00000000000..288e937f876 --- /dev/null +++ b/Python Program to Remove Punctuations From a String2.py @@ -0,0 +1,18 @@ +punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' + +my_str = "Hello!!!, he said ---and went." + +no_punct = "" +patch-2 +for char in my_str: + if char not in punctuations: + no_punct = no_punct + char + +for char in my_str: + +if char not in punctuations: + +no_punct = no_punct + char + +master +print(no_punct) \ No newline at end of file diff --git a/Random Password Generator1.py b/Random Password Generator1.py new file mode 100644 index 00000000000..5b01582cc82 --- /dev/null +++ b/Random Password Generator1.py @@ -0,0 +1,11 @@ +import random + +low="abcdefghijklmnopqrstuvwxyz" +upp="ABCDEFGHIJKLMNOPQRSTUVWXYZ" +num="0123456789" +sym="!@#$%^&*" + +all=low+upp+num+sym +length=8 +password="".join(random.sample(all,length)) +print(password) diff --git a/Random Password Generator2.py b/Random Password Generator2.py new file mode 100644 index 00000000000..0b1edc1c6d6 --- /dev/null +++ b/Random Password Generator2.py @@ -0,0 +1,57 @@ +import random + +LOWERCASE_CHARS = tuple(map(chr, xrange(ord('a'), ord('z')+1))) +UPPERCASE_CHARS = tuple(map(chr, xrange(ord('A'), ord('Z')+1))) +DIGITS = tuple(map(str, range(0, 10))) +SPECIALS = ('!', '@', '#', '$', '%', '^', '&', '*') + +SEQUENCE = (LOWERCASE_CHARS, + UPPERCASE_CHARS, + DIGITS, + SPECIALS, + ) + +def generate_random_password(total, sequences): + r = _generate_random_number_for_each_sequence(total, len(sequences)) + + password = [] + for (population, k) in zip(sequences, r): + n = 0 + while n < k: + position = random.randint(0, len(population)-1) + password += population[position] + n += 1 + random.shuffle(password) + + while _is_repeating(password): + random.shuffle(password) + + return ''.join(password) + +def _generate_random_number_for_each_sequence(total, sequence_number): + """ Generate random sequence with numbers (greater than 0). + The number of items equals to 'sequence_number' and + the total number of items equals to 'total' + """ + current_total = 0 + r = [] + for n in range(sequence_number-1, 0, -1): + current = random.randint(1, total - current_total - n) + current_total += current + r.append(current) + r.append(total - sum(r)) + random.shuffle(r) + + return r + +def _is_repeating(password): + """ Check if there is any 2 characters repeating consecutively """ + n = 1 + while n < len(password): + if password[n] == password[n-1]: + return True + n += 1 + return False + +if __name__ == '__main__': + print generate_random_password(random.randint(6, 30), SEQUENCE) \ No newline at end of file