forked from tdwojak/Python2017
changed files
This commit is contained in:
parent
9de284e666
commit
7ddeb4d38c
@ -5,8 +5,11 @@
|
||||
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
|
||||
"""
|
||||
|
||||
def days_in_year(days):
|
||||
pass
|
||||
def days_in_year(year):
|
||||
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
|
||||
return 366
|
||||
else:
|
||||
return 365
|
||||
|
||||
def tests(f):
|
||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||
|
@ -13,7 +13,14 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
|
||||
|
||||
|
||||
def oov(text, vocab):
|
||||
pass
|
||||
list_of_words = []
|
||||
text_splitted = text.split()
|
||||
# print(text_splitted)
|
||||
for word in text_splitted:
|
||||
if word.lower() not in vocab:
|
||||
list_of_words.append(word)
|
||||
return list_of_words
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -7,7 +7,18 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
||||
"""
|
||||
|
||||
def sum_from_one_to_n(n):
|
||||
pass
|
||||
# if n < 1:
|
||||
# return 0
|
||||
# else:
|
||||
# return sum(range(n + 1))
|
||||
ranges = range(n + 1)
|
||||
if n < 1:
|
||||
return 0
|
||||
else:
|
||||
return sum(ranges)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import math
|
||||
"""
|
||||
Napisz funkcję euclidean_distance obliczającą odległość między
|
||||
dwoma punktami przestrzeni trójwymiarowej. Punkty są dane jako
|
||||
@ -10,7 +10,10 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
||||
"""
|
||||
|
||||
def euclidean_distance(x, y):
|
||||
pass
|
||||
dist = [(a - b) ** 2 for a, b in zip(x, y)]
|
||||
dist = math.sqrt(sum(dist))
|
||||
return dist
|
||||
|
||||
|
||||
def tests(f):
|
||||
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
||||
|
@ -10,7 +10,9 @@ ma być zwracany napis "It's not a Big 'No!'".
|
||||
"""
|
||||
|
||||
def big_no(n):
|
||||
pass
|
||||
if n < 5:
|
||||
return "It's not a Big 'No!"
|
||||
new = n.split('N')
|
||||
|
||||
def tests(f):
|
||||
inputs = [[5], [6], [2]]
|
||||
|
@ -13,7 +13,7 @@ def pokemon_speak(text):
|
||||
|
||||
|
||||
def tests(f):
|
||||
inputs = [['pokemon'], ['do not want'], 'POKEMON']
|
||||
inputs = [['pokemon'], ['do not want'], ['POKEMON']]
|
||||
outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON']
|
||||
|
||||
for input, output in zip(inputs, outputs):
|
||||
|
Loading…
Reference in New Issue
Block a user