Primul commit si adaugat primu lab

Signed-off-by: Robert Nedela <robertnedela15@gmail.com>
This commit is contained in:
Robert Nedela
2026-03-10 17:50:00 +02:00
commit 9bb2630587
6 changed files with 132 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# Reverse string
hey = "hey"
print("Original string: " + hey)
print("Reversed string: " + hey[::-1])
# Alternate order for string
example = input("Please input a long string: ")
for i in range(len(example)):
if i % 2 == 0:
print(example[i], end="")
else:
print(example[i].capitalize(), end="")
print()
# Caesar cipher
cipherText = ""
for ch in example:
if ch.isalpha():
shifted_character = ord(ch) + 17
if shifted_character > ord('z'):
shifted_character -= 26
finalLetter = chr(shifted_character)
cipherText += finalLetter
print("Your ciphertext is: ", cipherText)
decryptedText = ""
for ch in cipherText:
if ch.isalpha():
shifted_character = ord(ch) - 17
if shifted_character < ord('a'):
shifted_character += 26
finalLetter = chr(shifted_character)
decryptedText += finalLetter
else:
decryptedText += ch
print("Mesajul descifrat este: ", decryptedText)