Skip to content

Commit b8fd625

Browse files
committed
finish character section
1 parent 7f3689b commit b8fd625

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

content/micropython/01.basics/08.reference/reference.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ For example:
6363
- [isControl()](#iscontrol)
6464
- [isDigit()](#isdigit)
6565
- [isGraph()](#isgraph)
66-
- [isHexadecimalDigit()](#ishexadecimaldigit)
6766
- [isLowerCase()](#islowercase)
6867
- [isPrintable()](#isprintable)
6968
- [isPunct()](#ispunct)
@@ -726,15 +725,51 @@ else:
726725
print(f"{char} is not a graph character.")
727726
```
728727

729-
### isHexadecimalDigit()
730-
<!-- TODO -->
731-
732728
### isLowerCase()
733-
<!-- TODO -->
729+
730+
**Example:**
731+
732+
`islower()`
733+
734+
```python
735+
char = 'a'
736+
737+
if char.islower():
738+
print("Is lower case.")
739+
else:
740+
print("Is not lower case.")
741+
```
742+
734743
### isPrintable()
735-
<!-- TODO -->
744+
745+
`isprintable()`
746+
747+
Checks if a character is printable, e.g. any character, including blank space, but not control characters.
748+
749+
**Example:**
750+
751+
```python
752+
char = '\t'
753+
754+
if char.isprintable():
755+
print("Is printable.")
756+
else:
757+
print("Is not printable.")
758+
```
759+
736760
### isPunct()
737-
<!-- TODO -->
761+
762+
There is no built-in function for checking punctuation in Python. Instead, we can define a variable containing all punctioation characters, and a function that compares the provided value with it.
763+
764+
**Example:**
765+
766+
```python
767+
def isPunct(char):
768+
punctuation_chars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
769+
return char in punctuation_chars
770+
771+
print(isPunct("."))
772+
```
738773

739774
### isSpace()
740775

0 commit comments

Comments
 (0)