computer science python
cipher_chr.py
def cipher_chr(a,b): c = ord(a) if c>=32 and c<126: d = c+b while d>126: d = d-126+32-1 e = chr(d) elif c<32: while c<32: c += 32 d = c+b e = chr(d) else: d = c-((c//32)*32)+b e = chr(d+1) print(e) return def main(): cipher_chr(str(input('Enter:')),int(input('Enter:'))) return main()
decipher_chr.py
def decipher_chr(): a = str(input('Enter:')) b = int(input('Enter:')) c = ord(a) if c>32 and c<=126: d = c-b while d<32: d = 126-32-d e = chr(d) elif c == 32: d = 126-b e = chr(d) print(e) return decipher_chr()
task3.py
def cipher_chr(a,b): c = ord(a) if c>=32 and c<126: d = c+b while d>126: d = d-126+32-1 e = chr(d) elif c<32: while c<32: c += 32 d = c+b e = chr(d) else: d = c-((c//32)*32)+b e = chr(d+1) return e def clear2cipher(): a = str(input('Enter:')) b = int(input('Enter:')) w = '' m = list(a) for i in m: n = cipher_chr(i,b) w += n print(w) return clear2cipher()
task4.py
def decipher_chr(a,b): c = ord(a) if c>32 and c<=126: d = c-b while d<32: d = 126-32-d e = chr(d) elif c == 32: d = 126-b e = chr(d) return return e def clear2cipher(): a = str(input('Enter:')) b = int(input('Enter:')) w = '' m = list(a) for i in m: n = decipher_chr(i,b) w += n print(w) return clear2cipher()
task5.py
def log_map(a,x): f = a*x*(1-x) return f def compare(): a = float(input('Enter the amplitude a:')) n = int(input('Enter the number of generations n:')) print('Enter the two initial populations:') xa = float(input()) xb = float(input()) print('Gen #', '\t\txa', '\t\t\txb', '\t\t\txa_xb') for i in range(0,n): xa = log_map(a,xa) xb = log_map(a,xb) xa_xb = xa-xb print(i+1, ' ', xa, ' ', xb, ' ', xa_xb) return def main(): compare() return main()