-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (48 loc) · 696 Bytes
/
main.py
File metadata and controls
48 lines (48 loc) · 696 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
42
43
44
45
46
47
48
def add(de, a, g):
if de == 0:
a -= g
a %= 26
return a
else:
a += g
a %= 26
return a
def calc(de, a, v, y):
if de == 0:
if v % 2 == 1:
a -= y
a %= 26
else:
a += y
a %= 26
else:
if v % 2 == 0:
a -= y
a %= 26
else:
a += y
a %= 26
return a
de = int(input("1 for - +, 0 for + -: "))
x = input().lower()
y = int(input("shift ratio: "))
z = len(x)
f = int(input("1 for addition shift, 0 for none: "))
if f == 1:
g = int(input("addition shift: "))
w = 0
v = 1
word = ""
while z != 0:
a = ord(x[w])
if a > 96 and a < 123:
a -= 97
if f == 1:
a = add(de, a, g)
a = calc(de, a, v, y)
a += 97
word += chr(a)
z -= 1
w += 1
v += 1
print(word)