<
Aug Day 4
Whiteboard Images
Warmup Topics
Warmup Coding Challenge
Introduction to Strings
Introduction to Strings Challenges
Project Requirements
Code Sections
Warmup
count = 1
while(count * count < 200):
print(count * count)
count = count + 1
String 1
# Print all chars
string = "hello world"
i = 0
while(i < len(string)):
print(string[i])
i = i + 1
# Print every other
i = 0
while(i < len(string)):
print(string[i])
i = i + 2
# Print random characters
import random
i = 0
while(i < len(string)):
print(string[random.randint(1,
len(string))])
i = i + 1
Char in string
string = "hello World"
char = 'l'
i = 0
found = False
while(i < len(string)):
if(string[i] == char):
found = True
break
i = i + 1
if(found):
print(char, "is in", string)
else:
print(char, "is not in", string)
Index of Char In String
string = "hello World"
char = 'l'
i = 0
found = False
foundIndex = -1
while(i < len(string)):
if(string[i] == char):
found = True
foundIndex = i
break
i = i + 1
if(found):
print(char, "is in", string, "at",
foundIndex)
else:
print(char, "is not in", string)
Has Uppercase
string = "hello World"
i = 0
found = False
while(i < len(string)):
if(string[i].isupper()):
found = True
break
i = i + 1
if(found):
print(string,"contains an uppercase")
else:
print(string,"does not contain an
uppercase")