# 实验4

print(sum)
sum = 42
print(sum)

def inc(n):
sum = n+1
print(sum)
return sum
sum = inc(7) + inc(7)
print(sum)

def func1(a, b, c, d, e, f):
return [a,b,c,d,e,f]

def func2(a, b, c,*, d, e, f):
return [a,b,c,d,e,f]

def func3(a, b, c, /, d, e, f):
return [a,b,c,d,e,f]

print( func1(1,9,2,0,5,3) )
print( func1(a=1, b=9, c=2, d=0, e=5, f=3) )
print( func1(1,9,2, f=3, d=0, e=5))

print( func2(11, 99, 22, d=0, e=55, f=33) )
print( func2(a=11, b=99, c=22, d=0, e=55, f=33) )

print( func3(111, 999, 222, 0, 555, 333))
print( func3(111, 999, 222, d=0, e=555, f=333))

list1 = [1, 9, 8, 4]

print( sorted(list1) )
print( sorted(list1, reverse=True) )
print( sorted(list1, True) )

def func(a, b, c, /, *, d, e, f):
return( [a,b,c,d,e,f] )

print(func(1,2,3,d=4,e=5,f=6))

def solve(a, b, c):
delta = b*b - 4*a*c
delta_sqrt = abs(delta)**0.5
p1 = -b/2/a;
p2 = delta_sqrt/2/a
if delta>=0:
root1 = p1 + p2
root2 = p1 - p2
else:
root1 = complex(p1, p2)
root2 = complex(p1, -p2)

return root1, root2

while True:
try:
a,b,c = eval(input('Enter eqution coefficient: '))
if a == 0:
raise
except:
print('invalid input, or, a is zero')
break
else:
root1, root2 = solve(a, b, c)
print(f'root1 = {root1:.2f}, root2 = {root2:.2f}')
print()
def is_prime(n):
if n==2:
return True
else:
a=2
for i in range(2,n):
if n%i==0:
return False
else:
a=a+1
if a==n:
return True
list1=[]
list2=[]
for i in range(1,21):
if is_prime(i)==True:
list1.append(i)
elif is_prime(i)==False:
list2.append(i)
for i in range(len(list2)):
z=1
x=0
y=0
while z!=0:
if int(list2[i])==int(list1[x])+int(list1[y]):
print(list2[i],'=',list1[x],'+',list1[y])
z=0
else:
y=y+1
if y==7:
x=x+1
y=x

z=0
x=str(input('输入英文文本：'))
for i in range(len(x)):
if 128>ord(x[i])+5>122 or 96>ord(x[i])+5>90:
a=ord(x[i])-21
z=z+1
elif 65<=ord(x[i])<=85 or 97<=ord(x[i])+5<=117:
a=ord(x[i])+5
z=z+1
else:
a=ord(x[i])
z=z+1
if z==1:
print('编码后的文本',end='')
print(chr(a),end='')
print()
print('对编码后的文本解码',x)