OOP Python Code — Key Concepts
import math
greeting = "Hello world!" # greeting OJBECT is an INSTANCE of the String CLASS
print(greeting)
print(type(greeting))
cnt = greeting.count("l")
print(cnt)
# Our Own Count Function -- We could write it!
def ourCount(phrase, letter):
ourCnt = 0
for c in phrase:
if c == letter:
# print("found one!")
ourCnt += 1
return ourCnt
print(ourCount(greeting, "l"))
x = math.sqrt(64) # call one of its METHODS
print(x)
print(math.pi) # reference one of it PROPERTIES
# Knowledge Check #1: identify examples of key concepts