Dodanie zadań do Lab1, Lab2, Lab3

This commit is contained in:
s498827 2024-12-02 19:19:02 +01:00
commit 0aece0d5f0
3 changed files with 32 additions and 0 deletions

3
Lab1/zad5.py Normal file
View File

@ -0,0 +1,3 @@
x = list(map(int, input().split()))
x = x[slice(1, x[0]+1)]
print(min(x) * max(x))

9
Lab2/zad6.py Normal file
View File

@ -0,0 +1,9 @@
queue = [1, 2, 3]
queue.append(4)
queue.append(5)
print(f"Queue after adding elements: {queue}")
queue.pop(0)
queue.pop(0)
print(f"Queue after removing elements: {queue}")

20
Lab3/zad7.py Normal file
View File

@ -0,0 +1,20 @@
def my_encode(message):
encoded_message = ''
for char in message:
encoded_message += chr(ord(char) + 7)
return encoded_message
def my_decode(message):
decoded_message = ''
for char in message:
decoded_message += chr(ord(char) - 7)
return decoded_message
message = "Witam"
encoded = my_encode(message)
decoded = my_decode(encoded)
print(f" Encoded: {encoded}")
print(f"Decoded: {decoded}")