Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Лабораторная работа вар12 #127

Open
wants to merge 5 commits into
base: Lebedev_Stepan_Petrovich
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions python/src/codewars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Evenor Odd
def even_or_odd(number):
if (number % 2) != 0:
return "Odd"
return "Even"


# Counting sheep...
def count_sheeps(sheep):
return sheep.count(True)


# Count the Monkeys!
def monkey_count(n):
result = []
for num in range(1, n + 1):
result.append(num)
return result


# Beginner Series #1 School Paperwork
def paperwork(n, m):
if n < 0 or m < 0:
return 0
else:
return n * m


# Is he gonna survive?
def hero(bullets, dragons):
return bullets >= (2 * dragons)


# Polish alphabet
def correct_polish_letters(st):
pol = pol = {"ą": "a", "ć": "c", "ę": "e", "ł": "l", "ń": "n", "ó": "o", "ś": "s", "ź": "z", "ż": "z"}
return "".join([pol[c] if c in pol else c for c in st])


# Sum of Minimums!
def sum_of_minimums(numbers):
return sum(map(min, numbers))


# Find all occurrences of an element in an array
def find_all(array, n):
indices = []
for i in range(len(array)):
if array[i] == n:
indices.append(i)
return indices
44 changes: 39 additions & 5 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
def summ(a: int, b: int) -> int:
return a + b
import math
from codewars import find_all, even_or_odd, correct_polish_letters, count_sheeps, monkey_count, hero, paperwork, sum_of_minimums
print(even_or_odd(2))
print(count_sheeps([True, True, True, False,
True, True, True, True,
True, False, True, False,
True, False, False, True,
True, True, True, True,
False, False, True, True]))
print(monkey_count(5))
print(paperwork(10, 10))
print(hero(20, 5))
print(correct_polish_letters("Jędrzej Błądziński"))
print(sum_of_minimums([[7, 9, 8, 6, 2], [6, 3, 5, 4, 3], [5, 8, 7, 4, 5]]))
print(find_all([6, 9, 3, 4, 3, 82, 11], 3))


if __name__ == "__main__":
print("Hello world")
print(summ(3, 4))
def frange(start, stop, step):

i = start
while i < stop:
yield i
i += step


def y(x):
y = (a**(x**2) - 1) - math.log10((x**2) - 1) + pow((x ** 2) - 1, 1 / 3)
return y


for x in frange(1.2, 3.7, 0.5):
a = 1.6
print(y(x))


xrange = [1.28, 1.36, 2.47, 3.68, 4.56]
xlen = len(xrange)
for i in range(0, xlen):
x = xrange[i]
a = 1.6
print(y(x))