Tasks solved

This commit is contained in:
Aleksander Misztal 2020-01-12 15:40:05 +01:00
parent bcb001350a
commit 4481e139c5
5 changed files with 29 additions and 0 deletions

6
intro/Task102.py Normal file
View File

@ -0,0 +1,6 @@
def add_three_numbers(x, y, z):
return x + y + z
if __name__ == '__main__':
print(add_three_numbers(2,5,7))
print(add_three_numbers(-3,-1,2))

5
intro/Task103.py Normal file
View File

@ -0,0 +1,5 @@
def probabilty(x):
if x >= 0 and x<=1:
return x
else:
return 0

5
intro/Task104.py Normal file
View File

@ -0,0 +1,5 @@
def farenheit(x):
if x< -273.15:
return -459.67
else:
return(x * 9/5) + 32

8
intro/Task105.py Normal file
View File

@ -0,0 +1,8 @@
def is_almost_prime(x, limit):
if x <0:
return False
else:
for y in range(2, limit+1):
if(x % y == 0):
return False
reutrn True

5
intro/Task106.py Normal file
View File

@ -0,0 +1,5 @@
def penultimate(list, otherwise):
if len(list) < 2:
return otherwise
else:
return list[-2]