forked from livinNector/python-programming-questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3. Data Processing IO
More file actions
113 lines (87 loc) · 1.27 KB
/
3. Data Processing IO
File metadata and controls
113 lines (87 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
title: Check if Three-Digit Odd Number
---
# Problem Statement
Given an integer `n`, return `True` if the number is a three-digit odd number, and `False` otherwise.
**Example**
```py3
is_three_digit_odd(123) # True , both three-digit and odd
is_three_digit_odd(22) # False, not three-digit
is_three_digit_odd(120) # False, three-digit but not odd
```
# Solution
```py3
def is_three_digit_odd(n: int) -> bool:
'''
Given an integer, check if it is a three-digit odd number.
Arguments:
n: int - an integer to check.
Return: bool - True if it is a three-digit odd number, else False.
'''
return 100 <= n <= 999 and n % 2 != 0
```
# Public Test Cases
## Input 1
```
is_equal(
is_three_digit_odd(135),
True
)
```
## Output 1
```
True
```
## Input 2
```
is_equal(
is_three_digit_odd(200),
False
)
```
## Output 2
```
False
```
## Input 3
```
is_equal(
is_three_digit_odd(99),
False
)
```
## Output 3
```
False
```
# Private Test Cases
## Input 1
```
n = 101
is_equal(
is_three_digit_odd(n),
True
)
n = 999
is_equal(
is_three_digit_odd(n),
True
)
n = 500
is_equal(
is_three_digit_odd(n),
False
)
n = 89
is_equal(
is_three_digit_odd(n),
False
)
```
## Output 1
```
True
True
False
False
```