以下為作業七內容
利用 iframe 嵌入投影片:
Jupyter notebook 檔案內容:
In [1]:
print("*")
In [2]:
print("***")
In [3]:
print("*")
print(" *")
print(" *")
In [4]:
print("*"*5)
In [5]:
for i in range(5):
print(i)
In [6]:
for i in range(1, 5):
print(i)
In [12]:
for i in range(1, 5):
if i != 3:
print(i)
In [13]:
for i in range(1, 5):
if i %2 == 0:
print(i)
In [14]:
for i in range(1, 5):
if i > 3:
print(i)
In [15]:
for i in range(1, 5):
if i >3 or i <2 :
print(i)
In [16]:
for i in range(1, 5):
if i < 5 and i > 2:
print(i)
In [17]:
for i in range(1, 5):
print("*"*i)
In [18]:
for i in range(5, 0, -1):
print("*"*i)
In [19]:
for i in range(1, 5):
print(" "*(i-1), end="")
print("*")
In [20]:
for i in range(5, 0, -1):
print(" "*(i-1), end="")
print("*")
In [21]:
for i in range(5):
print((5-i-1)*" ", end="")
print("*", end="")
print((2*i-1)*" ",end="")
if i != 0:
print("*", end="")
print((5-i-1)*" ", end="")
print()
In [22]:
for i in range(5-2, -1, -1):
print((5-i-1)*" ", end="")
print("*", end="")
print((2*i-1)*" ",end="")
if i != 0:
print("*", end="")
print((5-i-1)*" ", end="")
print()
In [23]:
for i in range(5):
print((5-i-1)*" ", end="")
print("*", end="")
print((2*i-1)*" ",end="")
if i != 0:
print("*", end="")
print((5-i-1)*" ", end="")
print()
for i in range(5-2, -1, -1):
print((5-i-1)*" ", end="")
print("*", end="")
print((2*i-1)*" ",end="")
if i != 0:
print("*", end="")
print((5-i-1)*" ", end="")
print()
In [24]:
def diamond(s):
for i in range(5):
print((5-i-1)*" ", end="")
print("o", end="")
print((2*i-1)*" ",end="")
if i != 0:
print("o", end="")
print((5-i-1)*" ", end="")
print()
for i in range(5-2, -1, -1):
print((5-i-1)*" ", end="")
print("o", end="")
print((2*i-1)*" ",end="")
if i != 0:
print("o", end="")
print((5-i-1)*" ", end="")
print()
diamond(10)
In [ ]:
w7_2015_11_10 from 40123210 on Vimeo.