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

add lab.py + codewars #144

Open
wants to merge 5 commits into
base: Tolukov_Aleksandr_Maksimovich
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
53 changes: 53 additions & 0 deletions python/codewars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# task 1
def even_or_odd(number):
if number % 2 == 0:
return "Even"
else:
return "Odd"


# task 2
def count_sheeps(sheep):
return sheep.count(True)


# task 3
def monkey_count(n):
result = []
for num in range(1, n + 1):
result.append(num)
return result


# task 4
def paperwork(n, m):
return n * m if n > 0 and m > 0 else 0


# task 5
def hero(b, d):
bulletsneeded = d * 2
if b >= bulletsneeded:
return True
else:
return False


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


# task 2
def find_all(array, n):
arr = []
for i in range(len(array)):
if array[i] == n:
arr.append(i)
return arr


# task 3
def sum_of_minimums(numbers):
return sum(map(min, numbers))
23 changes: 23 additions & 0 deletions python/src/lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

# задача A


def y(x):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a и b также параметры функции

a = 0.8
b = 0.4
y = ((((x - a) ** 2) ** (1.0 / 3)) + (abs(x + b) ** (1.0 / 5))) / ((x ** 2 - (a + b) ** 2) ** (1.0 / 9))
return y


x = 1.23
while x < 7.23:
print(y(x))
x += 1.2


# задача B
xrange = [1.88, 2.26, 3.84, 4.55, -6.21]
xlen = len(xrange)
for i in range(0, xlen):
x = xrange[i]
print(y(x))
Comment on lines +12 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выделите отдельные функции для задачи А и Б