codepython01
Giới thiệu
cicling: s+'abcde'
s=[start:stop:step]
a b c d e s[0:-1]
0 1 2 3 4
duyet
truc tiep
*lay gia tri thong qua vi tri
s[0]
*chuoi (str)
-len(s)
-'+' cong la de noi xau
-'' la de nhan,vd:'a'3=aaa
count de dem, vd: s.count(1) (dem ki tu '1')
set la them ki tu vo
*dem phan khoi
s=[4,5,7,78,9,9,0,6,4,2,]
a=[0](106+1)
for i in a:
công thức số số hạng(ssh):
ssh=(cuối-đầu)//khoảng cách+1
tổng=(cuối+đầu)ssh//2
tong so le =nn
tong so chan=n(n+1)
mang cong don:
def prefix_sum(s,x,y):
p = [0] * len(s)
p[0] = s[0]
for i in range(1, len(s)):
p[i] = p[i - 1] + s[i]
if x==0:
tong=p[y]
else:
tong=p[y]-(p[x-1])
return tong
s=[1,2,3,4,5,6,7]
print(prefix_sum(s,1,2))
from turtle import
from random import randint
colormode(255)
delay(-1)
def hv():
for i in range(100):
color(randint(0,255),randint(0,255),randint(0,255))
begin_fill()
for i in range(4):
fd(100);rt(90)
end_fill()
rt(360/100)
hv()
from turtle import *
from random import randint
delay(0)
colormode(255)
def ns(m,canh):
color(randint(0,255),randint(0,255),randint(0,255))
pd()
if canh==5: a=72
if canh==6: a=84
if canh==9: a=104
if canh==10: a=108
begin_fill()
for i in range(canh):
fd(m);rt(144);fd(m)
lt(a)
end_fill()
pu()
ns(100,9)