7**4
Run to view results
s = "Hi there Sam!"
list(s)
Run to view results
s.split()
Run to view results
planet = "Earth"
diameter = 12742
print('The diameter of {0} is {1} kilometers.'.format(planet,diameter))
Run to view results
Run to view results
lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7]
lst[3][1][2]
Run to view results
Run to view results
d = {'k1':[1,2,3,{'tricky':['oh','man','inception',{'target':[1,2,3,'hello']}]}]}
Run to view results
d['k1'][3]['tricky'][3]['target'][3]
Run to view results
# tuple is immutable, meaning can't add or change items.
# Example is days of week, which won't change
# can't add items to a tuple, only replace the whole tuple
Run to view results
email = "user@domain.com"
domain = email.split("@")
print(domain[1])
Run to view results
input_string = 'The cat was tired'
input_words = input_string.split()
print(input_words)
counter = 0
for word in input_words:
if word in ['dog', 'Dog']:
counter += 1
if counter > 0:
print('string contains ''dog'' or ''Dog''')
else:
print('string does not contain ''dog'' or ''Dog''')
Run to view results
input_string = 'The dog was dog tired'
input_words = input_string.split()
print(input_words)
counter = 0
for word in input_words:
if word in ['dog', 'Dog']:
counter += 1
print(f'Dog or dog was encountered {counter} times')
Run to view results
#speed = input('how fast were you driving?')
#is_birthday = True
def caught_speeding(speed, is_birthday):
if is_birthday == True:
speed -= 5
if speed <= 60:
print("No ticket")
elif speed >=61 and speed <=80:
print("Small ticket")
elif speed >=81:
print("Big Ticket")
pass
Run to view results
caught_speeding(81,True)
Run to view results
caught_speeding(81,False)
Run to view results