zrobione na zajeciach
This commit is contained in:
parent
bcb001350a
commit
11bee7e965
2
intro/Task102.py
Normal file
2
intro/Task102.py
Normal file
@ -0,0 +1,2 @@
|
||||
def add_three_numbers(x: int, y: int, z: int) -> int:
|
||||
return x + y + z
|
5
intro/Task103.py
Normal file
5
intro/Task103.py
Normal file
@ -0,0 +1,5 @@
|
||||
def probability(x: float) -> float:
|
||||
if 0 <= x <= 1:
|
||||
return x
|
||||
else:
|
||||
return 0
|
4
intro/Task104.py
Normal file
4
intro/Task104.py
Normal file
@ -0,0 +1,4 @@
|
||||
def fahrenheit(x: float) -> float:
|
||||
if x < -273.15:
|
||||
return -459.67
|
||||
return x * (9/5) + 32
|
8
intro/Task105.py
Normal file
8
intro/Task105.py
Normal file
@ -0,0 +1,8 @@
|
||||
def is_almost_prime(number: int, limit: int) -> bool:
|
||||
if number < 0:
|
||||
return False
|
||||
else:
|
||||
for i in range(2, limit+1):
|
||||
if number % i == 0:
|
||||
return False
|
||||
return True
|
5
intro/Task106.py
Normal file
5
intro/Task106.py
Normal file
@ -0,0 +1,5 @@
|
||||
def penultimate(l: list, otherwise: object) -> object:
|
||||
if (not l) or (len(l) == 1):
|
||||
return otherwise
|
||||
else:
|
||||
return l[-2]
|
11
intro/Task107.py
Normal file
11
intro/Task107.py
Normal file
@ -0,0 +1,11 @@
|
||||
def list_cubed(l: list) -> object:
|
||||
if not l:
|
||||
return 0
|
||||
|
||||
sum = 0
|
||||
|
||||
for i in range(l):
|
||||
sum = sum + (i*i*i)
|
||||
|
||||
return sum
|
||||
|
Loading…
Reference in New Issue
Block a user