last lab
This commit is contained in:
14
labPython/lab3/TextFile13.py
Executable file
14
labPython/lab3/TextFile13.py
Executable file
@@ -0,0 +1,14 @@
|
||||
def sum(A:int)->int:
|
||||
A = A * (1 - 2 * (A < 0))
|
||||
# A=abs(A)
|
||||
if A//10 > 0:
|
||||
return A%10 + sum(A//10)
|
||||
else:
|
||||
return A
|
||||
|
||||
num_end = int(input())
|
||||
num_multiply = int(input())
|
||||
with open("e.txt", "w") as file:
|
||||
for i in range(2, num_end+1):
|
||||
if sum(i) == sum(i*num_multiply):
|
||||
file.write(f"{i}\n")
|
||||
11
labPython/lab3/TextFile8.py
Executable file
11
labPython/lab3/TextFile8.py
Executable file
@@ -0,0 +1,11 @@
|
||||
with open("d.txt", "r") as file:
|
||||
maxX = 0
|
||||
minX = int(file.readline().replace("\n", ""))
|
||||
for x in file:
|
||||
x = int(x.replace("\n", ""))
|
||||
if maxX < x:
|
||||
maxX = x
|
||||
if minX > x:
|
||||
minX = x
|
||||
|
||||
print(f"max: {maxX}, min: {minX}, calculate: {maxX - minX}")
|
||||
6
labPython/lab3/b.txt
Executable file
6
labPython/lab3/b.txt
Executable file
@@ -0,0 +1,6 @@
|
||||
-1
|
||||
1
|
||||
-1
|
||||
1
|
||||
-1
|
||||
1
|
||||
25
labPython/lab3/d.txt
Executable file
25
labPython/lab3/d.txt
Executable file
@@ -0,0 +1,25 @@
|
||||
1
|
||||
1
|
||||
3
|
||||
5
|
||||
13
|
||||
21
|
||||
55
|
||||
89
|
||||
233
|
||||
377
|
||||
987
|
||||
1597
|
||||
4181
|
||||
6765
|
||||
1771
|
||||
28657
|
||||
75025
|
||||
121393
|
||||
317811
|
||||
514229
|
||||
1346269
|
||||
2178309
|
||||
5702887
|
||||
9227465
|
||||
24157817
|
||||
75
labPython/lab3/e.txt
Executable file
75
labPython/lab3/e.txt
Executable file
@@ -0,0 +1,75 @@
|
||||
9
|
||||
18
|
||||
27
|
||||
36
|
||||
45
|
||||
54
|
||||
72
|
||||
81
|
||||
90
|
||||
99
|
||||
108
|
||||
117
|
||||
135
|
||||
144
|
||||
171
|
||||
180
|
||||
189
|
||||
198
|
||||
207
|
||||
234
|
||||
270
|
||||
279
|
||||
288
|
||||
297
|
||||
342
|
||||
351
|
||||
360
|
||||
396
|
||||
405
|
||||
414
|
||||
441
|
||||
450
|
||||
459
|
||||
486
|
||||
495
|
||||
504
|
||||
540
|
||||
549
|
||||
558
|
||||
576
|
||||
585
|
||||
594
|
||||
639
|
||||
648
|
||||
657
|
||||
693
|
||||
702
|
||||
711
|
||||
720
|
||||
729
|
||||
756
|
||||
765
|
||||
783
|
||||
792
|
||||
801
|
||||
810
|
||||
819
|
||||
828
|
||||
846
|
||||
855
|
||||
864
|
||||
873
|
||||
882
|
||||
891
|
||||
900
|
||||
909
|
||||
918
|
||||
927
|
||||
936
|
||||
945
|
||||
954
|
||||
972
|
||||
981
|
||||
990
|
||||
999
|
||||
16
labPython/lab3/main.py
Executable file
16
labPython/lab3/main.py
Executable file
@@ -0,0 +1,16 @@
|
||||
# maxNum = 0
|
||||
# file = [1, 2, 2, 2, -10000, 52, 9999, 32, 12]
|
||||
#
|
||||
#
|
||||
#
|
||||
# for i in file:
|
||||
# delta = maxNum - i
|
||||
# delta = delta * (1 - 2 * (delta < 0))
|
||||
# sum = maxNum + i
|
||||
#
|
||||
# maxNum = (sum - delta) / 2 + delta
|
||||
#
|
||||
#
|
||||
# print (maxNum)
|
||||
|
||||
print(1%1)
|
||||
11
labPython/lab3/textfile17.py
Executable file
11
labPython/lab3/textfile17.py
Executable file
@@ -0,0 +1,11 @@
|
||||
with open("b.txt", "r") as file:
|
||||
num_this = 0
|
||||
is_subsequence = True
|
||||
lines = file.readlines()
|
||||
num_prev = int(lines[0].replace("\n", ""))
|
||||
for i in range(1, len(lines)):
|
||||
num_this = int(lines[i].replace("\n", ""))
|
||||
is_subsequence = ((num_prev>0)and(num_this<0))or((num_prev<0)and(num_this>0))and(is_subsequence)
|
||||
num_prev = int(lines[i].replace("\n", ""))
|
||||
|
||||
print(is_subsequence)
|
||||
19
labPython/lab3/textfile4.py
Executable file
19
labPython/lab3/textfile4.py
Executable file
@@ -0,0 +1,19 @@
|
||||
def fibonachi(num_for_stop:int) -> int:
|
||||
if num_for_stop <= 0:
|
||||
return 0
|
||||
elif num_for_stop == 1:
|
||||
return 1
|
||||
else:
|
||||
return fibonachi(num_for_stop-2) + fibonachi(num_for_stop-1)
|
||||
|
||||
num_end = int(input())
|
||||
|
||||
with open("d.txt", "w") as file:
|
||||
count = 0
|
||||
i=0
|
||||
while count < num_end:
|
||||
num_fib = fibonachi(i)
|
||||
if num_fib%2 == 1:
|
||||
file.write(f"{num_fib}\n")
|
||||
count+=1
|
||||
i +=1
|
||||
Reference in New Issue
Block a user