Boolean String tests - Introduction to Python: Absolute Beginner Module 1 Video 20

Pubblicato il: 26 luglio 2021
sul canale di: Book Simplifiers
165
4

Concept: Boolean String Tests

Boolean string tests return Bolean True or False
methods
.isalpha()
.isalnum()
.istitle()
.isdigit()
.islower()
.isupper()
.startswith()
type str has methods that return a Boolean (True or False) for different tests on the properties of stings.

"Hello".isalpha()
out:[ ] True

.isalpha() returns True if all characters in the string ("Hello") are alphabetical, otherwise returns False

Example
Boolean String Tests
[ ] review and run code in each cell
"Python".isalpha()
"3rd".isalnum()
"A Cold Stormy Night".istitle()
"1003".isdigit()
cm_height = "176"
print("cm height:",cm_height, "is all digits =",cm_height.isdigit())
print("SAVE".islower())
print("SAVE".isupper())
"Boolean".startswith("B")
Task 2: multi-part
test stings with .isalpha()
[ ] Use .isalpha() on the string "alphabetical"


[ ] Use .isalpha() on the string: "Are spaces and punctuation Alphabetical?"


[ ] initialize variable alpha_test with input

[ ] use .isalpha() on string variable alpha_test


In questa pagina del sito puoi guardare il video online Boolean String tests - Introduction to Python: Absolute Beginner Module 1 Video 20 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Book Simplifiers 26 luglio 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 165 volte e gli è piaciuto 4 spettatori. Buona visione!