Skip to content

Commit cb95d9d

Browse files
committed
part07 updated
1 parent 61aabb9 commit cb95d9d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

part07/01_hypotenuse.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from math import sqrt
2+
3+
4+
def hypotenuse(leg1: float, leg2: float):
5+
return sqrt(leg1 ** 2 + leg2 ** 2)

part07/02_special_characters.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import string
2+
3+
4+
def separate_characters(my_string: str):
5+
ascii_letters = []
6+
punctuations = []
7+
others = []
8+
for char in my_string:
9+
if char in string.ascii_letters:
10+
ascii_letters.append(char)
11+
elif char in string.punctuation:
12+
punctuations.append(char)
13+
else:
14+
others.append(char)
15+
16+
return ''.join(ascii_letters), ''.join(punctuations), ''.join(others)
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from fractions import Fraction
2+
3+
4+
def fractionate(amount: int):
5+
result = []
6+
for n in range(amount):
7+
result.append(Fraction(1, amount))
8+
return result

part07/04_lottery_numbers.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from random import sample
2+
3+
4+
def lottery_numbers(amount: int, lower: int, upper: int):
5+
number_pool = list(range(lower, upper))
6+
draw = sample(number_pool, amount)
7+
return sorted(draw)

0 commit comments

Comments
 (0)