test1.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import math
  2. def decorator_function(func_to_be_called):
  3. def wrapper(*args, **kwargs):
  4. print("Some text before calling function")
  5. func_to_be_called(*args, **kwargs)
  6. print("Some text after calling function")
  7. return wrapper
  8. @decorator_function
  9. def print_function(text):
  10. print("Your text is:", text)
  11. # print_function("Hello")
  12. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. from datetime import datetime
  14. def decorator_function(func_to_be_called):
  15. def wrapper(*args, **kwargs):
  16. print("Some text before calling function")
  17. func_to_be_called(*args, **kwargs)
  18. print("Some text after calling function")
  19. return wrapper
  20. def time_sum(func):
  21. def wrapper(text):
  22. d1 = datetime.now()
  23. print("Time before calling", d1)
  24. func(text)
  25. d2 = datetime.now()
  26. print("Time after calling", d2)
  27. print(d2 - d1)
  28. return wrapper
  29. @time_sum
  30. @decorator_function
  31. def print_function(text):
  32. print("Your text is:", text)
  33. # print_function("Hello")
  34. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. def decorator_function(func_to_be_called):
  36. def wrapper(text):
  37. print("Some text before calling function")
  38. result = func_to_be_called(text)
  39. print("Some text after calling function")
  40. return result
  41. return wrapper
  42. @decorator_function
  43. def print_function(text):
  44. return "Your text is: " + text
  45. # print(print_function("Hello"))
  46. def decorator(func):
  47. def wrapper(a, b):
  48. if a < 0 or b < 0:
  49. print("YES")
  50. result = func(a, b)
  51. return result
  52. return wrapper
  53. # Connect decorator please
  54. @decorator
  55. def main(a, b):
  56. return a + b
  57. # x, y = [int(x) for x in input().split()]
  58. # print(main(3, 6))
  59. # print(main(-3, 6))
  60. def test_exc_1(a, b):
  61. res = 0
  62. try:
  63. print(a/b)
  64. except Exception as e:
  65. print("Error:", Exception)
  66. def test_exc_2(a, b):
  67. res = 0
  68. try:
  69. print(a/b)
  70. except ZeroDivisionError:
  71. print("Error")
  72. except:
  73. print("Something another")
  74. def test_exc_3():
  75. try:
  76. a, b = int(input()), int(input())
  77. print(a +b)
  78. except:
  79. print("error")
  80. finally:
  81. print("end")
  82. def test_exc_4():
  83. try:
  84. a, b = int(input()), int(input())
  85. print(a + b)
  86. except:
  87. print("error")
  88. else:
  89. print("end")
  90. def test_raise():
  91. a, b = int(input()), int(input())
  92. if a + b == 3:
  93. raise RuntimeError("Oops, sum is 3")
  94. else:
  95. print(a + b)
  96. def is_prime(n):
  97. if n < 2:
  98. return False
  99. for i in range(2, int(math.sqrt(n)) + 1):
  100. if n%i == 0:
  101. return False
  102. return True
  103. # primes = [i for i in range(1, 20) if is_prime(i)]
  104. # print(primes)
  105. def task_1():
  106. print(len(input().split()))
  107. # task_1()
  108. def task_2():
  109. s1 = input()
  110. s2 = input()
  111. flag = True
  112. for i in s2:
  113. if i not in s1:
  114. flag = False
  115. print("Да, первая строка содержит все символы второй строки") if flag else print("Нет, первая строка не содержит все символы второй строки")
  116. task_2()
  117. s1 = input()
  118. s2 = input()
  119. flag = True
  120. for i in s2:
  121. if i not in s1:
  122. flag = False
  123. print("Да, первая строка содержит все символы второй строки") if flag else print("Нет, первая строка не содержит все символы второй строки")