File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ def circle_area (radius : float ) -> float :
2
+ """
3
+ >>> circle_area(10)
4
+ 314.1592653589793
5
+ >>> circle_area(0)
6
+ 0.0
7
+ """
8
+ import math
9
+
10
+ return math .pi * radius * radius
11
+
12
+
13
+ if __name__ == "__main__" :
14
+ from doctest import testmod
15
+
16
+ testmod ()
Original file line number Diff line number Diff line change
1
+ """
2
+ https://en.wikipedia.org/wiki/Leap_year
3
+ """
4
+
5
+
6
+ def is_leap_year (year : int ) -> bool :
7
+ """
8
+ >>> all(is_leap_year(year) for year in [1600, 2000, 24000])
9
+ True
10
+ >>> all(is_leap_year(year) for year in [1999, 2001, 2002])
11
+ False
12
+ """
13
+ return year % 4 == 0 and year % 100 != 0 or year % 400 == 0
14
+
15
+
16
+ if __name__ == "__main__" :
17
+ from doctest import testmod
18
+
19
+ testmod ()
Original file line number Diff line number Diff line change
1
+ def sum_to_n (n : int ) -> int :
2
+ """
3
+ >>> sum_to_n(100)
4
+ 5050
5
+ >>> sum_to_n(10)
6
+ 55
7
+ """
8
+ return sum (i for i in range (1 , n + 1 ))
9
+
10
+
11
+ if __name__ == "__main__" :
12
+ from doctest import testmod
13
+
14
+ testmod ()
You can’t perform that action at this time.
0 commit comments