Задача 1:
minnum, maxnum = int(1e15), int(-1e15)
cur = 1
while True:
cur = int(input())
if cur == 0:
break
minnum = min(minnum, cur)
maxnum = max(maxnum, cur)
print("Min = " + str(minnum) + "\nMax = " + str(maxnum))
Задача 2:
def Fib(n):
if n == 1 or n == 2:
return 1
return Fib(n - 1) + Fib(n - 2)
for i in range(5):
n = int(input())
print(str(n) + " term of Fibonacci sequence is " + str(Fib(n)))
Задача 3:
import random
a = list()
for i in range(n):
a.append(random.randint(-100, 100))
print("before deleting:")
print(*a, sep=' ')
if(a[i] < 0):
a.remove(a[i])
print("\nafter deleting:")
Задача 4:
s = map(str, input().split())
c = str(input())
cnt = 0
for i in s:
hasChar = False
print(i)
for j in i:
if j == c:
hasChar = True
if hasChar:
cnt += 1
print(cnt)
Задача 1:
minnum, maxnum = int(1e15), int(-1e15)
cur = 1
while True:
cur = int(input())
if cur == 0:
break
minnum = min(minnum, cur)
maxnum = max(maxnum, cur)
print("Min = " + str(minnum) + "\nMax = " + str(maxnum))
Задача 2:
def Fib(n):
if n == 1 or n == 2:
return 1
return Fib(n - 1) + Fib(n - 2)
for i in range(5):
n = int(input())
print(str(n) + " term of Fibonacci sequence is " + str(Fib(n)))
Задача 3:
import random
n = int(input())
a = list()
for i in range(n):
a.append(random.randint(-100, 100))
print("before deleting:")
print(*a, sep=' ')
for i in range(n):
if(a[i] < 0):
a.remove(a[i])
break
print("\nafter deleting:")
print(*a, sep=' ')
Задача 4:
s = map(str, input().split())
c = str(input())
cnt = 0
for i in s:
hasChar = False
print(i)
for j in i:
if j == c:
hasChar = True
if hasChar:
cnt += 1
print(cnt)