Files
Robert Nedela 9bb2630587 Primul commit si adaugat primu lab
Signed-off-by: Robert Nedela <robertnedela15@gmail.com>
2026-03-10 17:50:00 +02:00

43 lines
1.0 KiB
Python

#!/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)