Substrings, Casting & ASCII Logic.
CHR(ASC('A') + 3)ASC('c') - ASC('a')CHR(50) (Note: '0' is 48)(a) Case-sensitive comparison. "Start" != "START".
(b) if command.upper() == "START":
Trace Table:
| count | letter | newText | Output |
|---|---|---|---|
Output: R-O-B-
(Loops 0, 1, 2. Extracts R, O, B. Appends hyphen each time).
getInitials(name) that returns uppercase initials.
function getInitials(name)
first = name.substring(0, 1)
spacePos = name.index(" ")
second = name.substring(spacePos + 1, 1)
combined = first + second
return combined.upper()
endfunction
Reason: String methods return a new string, they don't change the original.
Fix: name = name.upper()
module = "Computer Science"
module.substring(0, 4)module.right(3)module.length
pw = input("Password: ")
while len(pw) < 8:
print("Too short")
pw = input("Password: ")
word1 = "Apple", word2 = "Zebra"
word1.length == 5word1 < word2word1.substring(0, 1) == "a"