In [2]:
apikey="SECRET!!"
In [5]:
for x in range(1,101):
if x %3==0 and x %5==0:
print("fizzbuzz")
elif x %3==0:
print("fizz")
elif x %5==0:
print("buzz")
else:
print(int(x))
In [7]:
for x in range(1, 101):
outstring = ""
if x % 3 == 0:
outstring += "fizz"
if x % 5 == 0:
outstring += "buzz"
if outstring:
print(outstring)
else:
print(x)
In [8]:
for x in range (1, 101):
if x%3==0:
print('fizz')
elif x%5==0:
print('buzz')
elif (x%3==0 & x%5==0):
print('fizzbuzz')
else:
print (x)
In [9]:
if x == cat:
do_something()
else if x == dog:
do_something_else()
else if x == bear:
do_a_third_thing()
In [12]:
for x in range(1,101):
if x %3==0 and x %5==0:
print("fizzbuzz")
elif x %3==0:
print("fizz")
elif x %5==0:
print("buzz")
In [13]:
for x in range(1, 101):
outstring = ""
if x % 3 == 0:
outstring += "fizz"
if x % 5 == 0:
outstring += "buzz"
if outstring:
print(outstring)
if not outstring:
print(x)
In [15]:
def fizzbuzz(start,end):
for x in range (start,end + 1):
if x % 3 == 0 and x % 5 == 0:
print("fizzbuzz")
elif x % 3 == 0:
print("fizz")
elif x % 5 ==0:
print("buzz")
else:
print(x)
fizzbuzz(1,16)
In [16]:
fizzbuzz(-20, 20)
In [17]:
print(fizzbuzz(1,16))
In [18]:
x = fizzbuzz(1, 16)
In [19]:
print(x)
In [21]:
def fizzbuzz_test(x):
if x % 3 == 0 and x % 5 == 0:
return "fizzbuzz"
elif x % 3 == 0:
return "fizz"
elif x % 5 ==0:
return "buzz"
else:
return x
In [22]:
def fizzbuzz2(start, stop):
for x in range(start, stop + 1):
print(fizzbuzz_test(x))
In [23]:
fizzbuzz2(1, 16)
In [26]:
def fizzbuzz3(start, stop):
outstring = ""
for x in range(start, stop+1):
outstring += str(fizzbuzz_test(x)) + "\n"
return outstring
In [27]:
print(fizzbuzz3(1, 16))
In [28]:
import datetime
In [29]:
print(datetime.datetime.now())
In [30]:
import mylib
In [31]:
print(mylib.dog)
In [32]:
print(mylib.cat)
In [33]:
from mylib import cat
In [34]:
print(cat)
In [36]:
from datetime import datetime
In [37]:
datetime.now()
Out[37]:
In [38]:
from mylib import *
In [39]:
print(dog)
In [ ]: