diff options
author | Sudipto Mallick <smlckz@termux-alpine> | 2024-01-13 09:28:10 +0530 |
---|---|---|
committer | Sudipto Mallick <smlckz@termux-alpine> | 2024-01-13 09:28:10 +0530 |
commit | 8fb719f58f91d1f1f187a1db974682fb3736ee05 (patch) | |
tree | 506e070c7900cc5e3fb31000dbd1a39e95809c61 /python/code/3 | |
parent | 53d75846cc95a3af5d90c01b5ef010818b4adcf7 (diff) | |
download | zadania-8fb719f58f91d1f1f187a1db974682fb3736ee05.tar.gz |
Changes to project structure of Python assignments
As was directed to remove assignments.
Diffstat (limited to 'python/code/3')
-rw-r--r-- | python/code/3/3.py | 11 | ||||
-rw-r--r-- | python/code/3/4.py | 25 | ||||
-rw-r--r-- | python/code/3/5.py | 5 | ||||
-rw-r--r-- | python/code/3/6.py | 27 | ||||
-rw-r--r-- | python/code/3/7.py | 9 |
5 files changed, 0 insertions, 77 deletions
diff --git a/python/code/3/3.py b/python/code/3/3.py deleted file mode 100644 index 7f9a98f..0000000 --- a/python/code/3/3.py +++ /dev/null @@ -1,11 +0,0 @@ -full_name = input("Enter your full name: ") -space_index = full_name.rfind(' ') - -if space_index == -1: - print(f"Your name in reverse: {full_name}") -else: - first_name = full_name[:full_name.index(' ')] - last_name = full_name[space_index + 1:] - print(f"Your name in reverse: {last_name}, {first_name}") - - diff --git a/python/code/3/4.py b/python/code/3/4.py deleted file mode 100644 index 3c0a566..0000000 --- a/python/code/3/4.py +++ /dev/null @@ -1,25 +0,0 @@ -def our_str_count(s, sub, start=None, end=None): - ss = s[slice(start, end)] - if len(sub) == 0: return len(ss) + 1 - elif len(ss) < len(sub): return 0 - i, l, ls = 0, len(ss), len(sub) - count = 0 - while i < l: - if ss[i:i+ls] == sub: - count += 1 - i += ls - else: - i += 1 - return count - -s = input('Enter a string: ') -sub = input('Enter substring to count: ') -idcs = input('Enter starting and ending indices (default: whole string): ') -if len(idcs) == 0: - idcs = (None, None) -else: - idcs = (int(i) for i in idcs.split()) -start, end = idcs - -print('Count:', our_str_count(s, sub, start, end)) - diff --git a/python/code/3/5.py b/python/code/3/5.py deleted file mode 100644 index 7db13a0..0000000 --- a/python/code/3/5.py +++ /dev/null @@ -1,5 +0,0 @@ -text = input('Enter a line of text: ') -vowels = set('aeiouAEIOU') -ctext = ''.join(c for c in text if c not in vowels) -print('Given text with all vowels removed:', ctext) - diff --git a/python/code/3/6.py b/python/code/3/6.py deleted file mode 100644 index 64b1a60..0000000 --- a/python/code/3/6.py +++ /dev/null @@ -1,27 +0,0 @@ -import sys -message = input('Enter message: ') -key = None -try: - key = int(input('Enter key (1-25, -1 - -25): ')) -except ValueError: - print('Invalid key, must be an integer') - sys.exit(1) - -if key < 0: key += 26 -if not (1 <= key <= 25): - print('Invalid key, must be an integer with absolute value between 1 and 25, inclusive') - sys.exit(2) - -marr = bytearray(message, 'ascii') -for i in range(len(marr)): - c = marr[i] - if 64 < c < 64 + 27: - c = ((c - 65) + key) % 26 + 65 - elif 96 < c < 96 + 27: - c = ((c - 97) + key) % 26 + 97 - marr[i] = c - -print('Caesar cipher with k =', key, 'applied to the given message:') -print(str(marr, encoding='ascii')) - - diff --git a/python/code/3/7.py b/python/code/3/7.py deleted file mode 100644 index 7a17f08..0000000 --- a/python/code/3/7.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -address = input('Enter an E-mail address: ') -if '@' not in address: - print(address, 'is not a valid E-mail address') - sys.exit(1) -at_position = address.rindex('@') -username, domain = address[:at_position], address[at_position+1:] -print('Username:', username) -print('Domain:', domain) |