-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest3.py
More file actions
41 lines (30 loc) · 744 Bytes
/
Copy pathtest3.py
File metadata and controls
41 lines (30 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
print("String Reverse and ASCII Test")
print()
text = input("Enter a string: ")
# Reverse string
reversed_text = ""
i = len(text) - 1
while i >= 0:
reversed_text = reversed_text + text[i]
i = i - 1
print()
print("Original:", text)
print("Reversed:", reversed_text)
print()
print("Character Analysis")
print("------------------")
ascii_product = 1
i = 0
while i < len(text):
ch = text[i]
code = ord(ch)
print(ch, "->", code)
try:
ascii_product = ascii_product * code
except OverflowError:
print("Overflow occurred with character:", ch)
ascii_product = 0
break
i = i + 1
print()
print("ASCII multiplication result:", ascii_product)