ITÊýÂë ¹ºÎï ÍøÖ· Í·Ìõ Èí¼þ ÈÕÀú ÔĶÁ ͼÊé¹Ý
TxTС˵ÔĶÁÆ÷
¡ýÓïÒôÔĶÁ,С˵ÏÂÔØ,¹ÅµäÎÄѧ¡ý
ͼƬÅúÁ¿ÏÂÔØÆ÷
¡ýÅúÁ¿ÏÂÔØͼƬ,ÃÀŮͼ¿â¡ý
ͼƬ×Ô¶¯²¥·ÅÆ÷
¡ýͼƬ×Ô¶¯²¥·ÅÆ÷¡ý
Ò»¼üÇå³ýÀ¬»ø
¡ýÇáÇáÒ»µã,Çå³ýϵͳÀ¬»ø¡ý
¿ª·¢: C++֪ʶ¿â Java֪ʶ¿â JavaScript Python PHP֪ʶ¿â È˹¤ÖÇÄÜ Çø¿éÁ´ ´óÊý¾Ý Òƶ¯¿ª·¢ ǶÈëʽ ¿ª·¢¹¤¾ß Êý¾Ý½á¹¹ÓëËã·¨ ¿ª·¢²âÊÔ ÓÎÏ·¿ª·¢ ÍøÂçЭÒé ϵͳÔËά
½Ì³Ì: HTML½Ì³Ì CSS½Ì³Ì JavaScript½Ì³Ì GoÓïÑÔ½Ì³Ì JQuery½Ì³Ì VUE½Ì³Ì VUE3½Ì³Ì Bootstrap½Ì³Ì SQLÊý¾Ý¿â½Ì³Ì CÓïÑÔ½Ì³Ì C++½Ì³Ì Java½Ì³Ì Python½Ì³Ì Python3½Ì³Ì C#½Ì³Ì
ÊýÂë: µçÄÔ ±Ê¼Ç±¾ ÏÔ¿¨ ÏÔʾÆ÷ ¹Ì̬ӲÅÌ Ó²ÅÌ ¶ú»ú ÊÖ»ú iphone vivo oppo СÃ× »ªÎª µ¥·´ ×°»ú ͼÀ­¶¡
 
   -> Python֪ʶ¿â -> python task 4Á·Ï° -> ÕýÎÄÔĶÁ

[Python֪ʶ¿â]python task 4Á·Ï°

Êý¾ÝÀàÐÍÏà¹ØÁ·Ï°

Êý¾ÝÀàÐÍÏà¹ØÁ·Ï°

# str->int ×Ö·û´®(str) PythonµÄÖ÷ÒªÊýÖµÀàÐÍÊÇintºÍfloat¡£int¿ÉÒÔ´æ´¢ÈÎÒâ?µÄÊý
#Python ×Öµä(Dictionary) type() º¯Êý·µ»ØÊäÈëµÄ±äÁ¿ÀàÐÍ,Èç¹û±äÁ¿ÊÇ×Öµä¾Í·µ»Ø×ÖµäÀàÐÍ¡£
# type(dict)Óï·¨
X=int('ABCD',16)
print(X)
type(X)#Çø·Ö´óСд×Öĸ

# float -> str
a = 5.99
b = str(a)
print(b)

# int -> float
a = 520.11
d = float(a)
d
print(d)
# float-> int 
a = 520.11
e = int(a)
e
print(e)

a_string='hello'+''+"Women Who Code!"
print(a_string)
print("str[0]:"+a_string[0])#0λÖÿªÊ¼¾ÍÊÇH
print("str[2:5]:" + a_string[2:5])#µÚ¶þ¸öλÖÿªÊ¼ÊÇl,2~5λ110
print("str[2:] :" + a_string[2:])#µÚ¶þ¸öλÖÿªÊ¼ºóºóÃæËùÓÐ
43981
5.99
520.11
520
helloWomen Who Code!
str[0]:h
str[2:5]:llo
str[2:] :lloWomen Who Code!

Áбí²Ù×÷

#ÁбíÊǸö¿ò,ʲô¶¼¿ÉÒÔÍùÀï×°
lis = [ "WWCode", 786 , 2.23, 'singapore', 70.2 ]
print(lis[0:3])
type(lis)

#ÁбíµÄË÷Òý,ÏȲ²ÂÏÂÃæÕâ¸öµ¥Ôª¸ñÄܵõ½Ê²Ã´,ÔÙÔËÐÐ
lis = [ "WWCode", 786 , 2.23, 'singapore', 50 ]
print(lis[3][0:4])#0¿ªÊ¼,ÁбíµÄµÚËĸö×Ö·û,È¡ÆäÖÐËÄλÊý


print(lis[3][0:4])

lis[2] = 3.3
print(lis)#µÚ¶þλÌæ»»³É3.3

symbols = '$¡é¡ê£¤€¡è'
codes = [ord(symbol) for symbol in symbols]
codes
['WWCode', 786, 2.23]
sing
sing
['WWCode', 786, 3.3, 'singapore', 50]





[36, 162, 163, 165, 8364, 164]

Ôª×é²Ù×÷

t1 = ( "WWCode", 100000 , 0.5 ) # 
t2 = 'Singapore', 1160.5
t_singleton = ('We',) 
t_empty = ()
print(type(t1)); print(type(t2))
print(t_singleton);
type(t_empty)
#Ôª×é²»Ö§³Ö¶ÔÏó¸³Öµ,PythonµÄÔª×éÓëÁбíÀàËÆ,²»Í¬Ö®´¦ÔÚÓÚÔª×éµÄÔªËز»ÄÜÐ޸ġ£Ôª×éʹÓÃСÀ¨ºÅ,ÁбíʹÓ÷½À¨ºÅ¡£Ôª×é´´½¨ºÜ¼òµ¥,Ö»ÐèÒªÔÚÀ¨ºÅÖÐÌí¼ÓÔªËØ,²¢Ê¹ÓöººÅ¸ô¿ª¼´¿É
<class 'tuple'>
<class 'tuple'>
('We',)





tuple

×Öµä²Ù×÷

×ÖµäÊÇÁíÒ»ÖֿɱäÈÝÆ÷Ä£ÐÍ,ÇÒ¿É´æ´¢ÈÎÒâÀàÐͶÔÏó¡£

×ÖµäµÄÿ¸ö¼üÖµ key=>value ¶ÔÓÃðºÅ : ·Ö¸î,ÿ¸ö¼üÖµ¶ÔÖ®¼äÓöººÅ , ·Ö¸î,Õû¸ö×Öµä°üÀ¨ÔÚ»¨À¨ºÅ {} ÖÐ

dict1 = {'name':'Women Who Code Singapore', 
        'org':'WWCode', 
        'city':'Singapore',
        'members':1260}
print(dict1['org'])
type(dict1)

# Ôö¼ÓÔªËØ
dict1['rank'] = 10
dict1['abcde']=10000 
print(dict1)

# »ñÈ¡ÔªËØ
dict1['org']
print(dict1['org'])

# »ñÈ¡²»ÖªÊÇ·ñ´æÔÚµÄÔªËØ
dict1.get('org','²»´æÔÚ')

# »ñÈ¡²»ÖªÊÇ·ñ´æÔÚµÄÔªËØ
dict1.get('ord','²»´æÔÚ')#Èç¹û²»´æÔÚÔò·µ»Ø¡®²»´æÔÚ¡¯
WWCode
{'name': 'Women Who Code Singapore', 'org': 'WWCode', 'city': 'Singapore', 'members': 1260, 'rank': 10, 'abcde': 10000}
WWCode





'²»´æÔÚ'

Sets ¼¯ºÏ

¼¯ºÏ(set)ÊÇÒ»¸öÎÞÐòµÄ²»Öظ´ÔªËØÐòÁС£

¿ÉÒÔʹÓôóÀ¨ºÅ { } »òÕß set() º¯Êý´´½¨¼¯ºÏ,×¢Òâ:´´½¨Ò»¸ö¿Õ¼¯ºÏ±ØÐëÓà set() ¶ø²»ÊÇ { },ÒòΪ { } ÊÇÓÃÀ´´´½¨Ò»¸ö¿Õ×ֵ䡣

´´½¨¸ñʽ:parame = {value01,value02,...}
»òÕß
set(value)

wwcode_asia_networks = {'Bangalore','Beijing','Chennai','Delhi','Gujarat','Hong Kong','Kuala Lumpur'}
type(wwcode_asia_networks)
print(wwcode_asia_networks)
#ÒƳýÔªËØ
wwcode_asia_networks .remove('Delhi')
print(wwcode_asia_networks)


#Ëæ»úɾ³ýÔªËØ
wwcode_asia_networks.pop() 
print(wwcode_asia_networks)


#ÅжÏÔªËØÔÚ²»ÔÚÀïÃæ
t =set(("Bangalore","Beijing"))
'Hong Kong' in t


#Íù¼¯ºÏÀïÔö¼ÓÔªËØ
wwcode_asia_networks.update({1,3})
wwcode_asia_networks=t
print(t)
len(wwcode_asia_networks)#¼ÆËãÔªËصĸöÊý

#Íù¼¯ºÏÀïÔö¼ÓÔªËØ
wwcode_asia_networks=t
t.add(500)
print(t)

#Çå¿Õ¼¯ºÏ
wwcode_asia_networks.clear()
print(wwcode_asia_networks)

ÔËËãºÍ²¼¶ûÔËËã

#ÔËËã·û ÃèÊö ʵÀý
= ¼òµ¥µÄ¸³ÖµÔËËã·û c = a + b ½« a + b µÄÔËËã½á¹û¸³ÖµÎª c
+= ¼Ó·¨¸³ÖµÔËËã·û c += a µÈЧÓÚ c = c + a
-= ¼õ·¨¸³ÖµÔËËã·û c -= a µÈЧÓÚ c = c - a
*= ³Ë·¨¸³ÖµÔËËã·û c *= a µÈЧÓÚ c = c * a
/= ³ý·¨¸³ÖµÔËËã·û c /= a µÈЧÓÚ c = c / a
%= È¡Ä£¸³ÖµÔËËã·û c %= a µÈЧÓÚ c = c % a
**= Ãݸ³ÖµÔËËã·û c **= a µÈЧÓÚ c = c ** a
//= È¡Õû³ý¸³ÖµÔËËã·û c //= a µÈЧÓÚ c = c // a

x = 1 + 2 # ¼Ó
y = 3 - 4 # ¼õ
z = 5 * 6 # ³Ë
a = z / y # ³ý
b = z % x # ÓàÊý
c = y ** x # Ö¸ÊýXÊÇyµÄÖ¸Êý
d = c // x # È¡Õû³ý - ÏòÏÂÈ¡½Ó½üÉ̵ÄÕûÊý
print(b)
print("x:" + str(x) + " y:" + str(y) + " z:" + str(z) + 
      " a:" + str(a) + " b:" + str(b) + " c:" + str(c) + " d:" + str(d))

#Ö¸Êý
x=2
y=4
c=x**y
print(c)

#Ö¸Êý
x=9
y=2
c=x//y
print(c)# È¡Õû³ý - ÏòÏÂÈ¡½Ó½üÉ̵ÄÕûÊý 9/2=4.5È¡Õû¹Ê4

print(a == b) 
print(a != b)
print(a > b)  
print(a < b)  
print(a >= b) 
print(a <= b)

0
x:3 y:-1 z:30 a:-30.0 b:0 c:-1 d:-1
16
4
False
True
False
True
False
True
#Logical Operators Âß¼­ÔËËã·ûand or not
#Êý×é,Ôª×é,Áбí,¼¯ºÏ,¸³Öµºó¶¼ÊÊÓÃÓÚand or not Âß¼­
a_string = "Women Who Code"
print("Women" in a_string)
print("Men" not in a_string)
print(len("Women Who Code") is len(a_string))
print(len("Hello World!") is not len(a_string))
# Êý×é±È½Ï 
#is ºÍ is not ÔËËã·û Óë==ÒÔ¼°!=µÄÇø±ð
#is ÓÃÓÚÅжÏÁ½¸ö±äÁ¿ÒýÓöÔÏóÊÇ·ñΪͬһ¸ö, == ÓÃÓÚÅжÏÒýÓñäÁ¿µÄÖµÊÇ·ñÏàµÈ¡£
x = [1, 2, 3]
y = [1, 2, 3]
print(x == y)
print(x is y)
print(id(x))
print(id(y))

# Ôª×é±È½Ï
#id() º¯Êý·µ»Ø¶ÔÏóµÄΨһ±êʶ·û,±êʶ·ûÊÇÒ»¸öÕûÊý¡£
#Python ÖÐ id() º¯ÊýÓÃÓÚ»ñÈ¡¶ÔÏóµÄÄÚ´æµØÖ·
x = (1, 2, 3)
y = (1, 2, 3)
print(x == y)
print(x is y)
print(id(x))
print(id(y))

# ×Öµä±È½Ï
x = {"id": 1, "name": "Tom", "age": 18}
y = {"id": 1, "name": "Tom", "age": 18}
print(x == y)
print(x is y)
print(id(x))
print(id(y))

# ¼¯ºÏ±È½Ï
x = set([1, 2, 3])
y = set([1, 2, 3])
print(x == y)
print(x is y)
print(id(x))
print(id(y))

# ¸³Öµºó±È½Ï
x = [1, 2, 3]
y = x
print(x == y)
print(x is y)#¶ÔÏóÏàµÈ,ËùÒÔÊÇture
print(id(x))
print(id(y))

#¿ÕÖµ±È½Ï
none_type = None
none_type is None

True
True
True
True
True
False
1824923598400
1824927357440
True
False
1824934194112
1824923855360
True
False
1824931618560
1824923598208
True
False
1824925829376
1824935470688
True
True
1824927358016
1824927358016





True
  Python֪ʶ¿â ×îÐÂÎÄÕÂ
PythonÖÐStringÄ£¿é
¡¾Python¡¿ 14-CVSÎļþ²Ù×÷
pythonµÄpanda¿â¶ÁдÎļþ
ʹÓÃNordicµÄnrf52840ʵÏÖÀ¶ÑÀDFU¹ý³Ì
¡¾Pythonѧϰ¼Ç¼¡¿numpyÊý×éÓ÷¨ÕûÀí
Pythonѧϰ±Ê¼Ç
python×Ö·û´®ºÍÁбí
pythonÈçºÎ´ÓtxtÎļþÖнâÎö³öÓÐЧµÄÊý¾Ý
Python±à³Ì´ÓÈëÃŵ½Êµ¼ù×Ôѧ/3.1-3.2
python±äÁ¿
ÉÏһƪÎÄÕ      ÏÂһƪÎÄÕ      ²é¿´ËùÓÐÎÄÕÂ
¼Ó:2022-02-26 11:26:58  ¸ü:2022-02-26 11:28:07 
 
¿ª·¢: C++֪ʶ¿â Java֪ʶ¿â JavaScript Python PHP֪ʶ¿â È˹¤ÖÇÄÜ Çø¿éÁ´ ´óÊý¾Ý Òƶ¯¿ª·¢ ǶÈëʽ ¿ª·¢¹¤¾ß Êý¾Ý½á¹¹ÓëËã·¨ ¿ª·¢²âÊÔ ÓÎÏ·¿ª·¢ ÍøÂçЭÒé ϵͳÔËά
½Ì³Ì: HTML½Ì³Ì CSS½Ì³Ì JavaScript½Ì³Ì GoÓïÑÔ½Ì³Ì JQuery½Ì³Ì VUE½Ì³Ì VUE3½Ì³Ì Bootstrap½Ì³Ì SQLÊý¾Ý¿â½Ì³Ì CÓïÑÔ½Ì³Ì C++½Ì³Ì Java½Ì³Ì Python½Ì³Ì Python3½Ì³Ì C#½Ì³Ì
ÊýÂë: µçÄÔ ±Ê¼Ç±¾ ÏÔ¿¨ ÏÔʾÆ÷ ¹Ì̬ӲÅÌ Ó²ÅÌ ¶ú»ú ÊÖ»ú iphone vivo oppo СÃ× »ªÎª µ¥·´ ×°»ú ͼÀ­¶¡

360ͼÊé¹Ý ¹ºÎï Èý·á¿Æ¼¼ ÔĶÁÍø ÈÕÀú ÍòÄêÀú 2024Äê11ÈÕÀú -2024/11/16 0:51:55-

ͼƬ×Ô¶¯²¥·ÅÆ÷
¡ýͼƬ×Ô¶¯²¥·ÅÆ÷¡ý
TxTС˵ÔĶÁÆ÷
¡ýÓïÒôÔĶÁ,С˵ÏÂÔØ,¹ÅµäÎÄѧ¡ý
Ò»¼üÇå³ýÀ¬»ø
¡ýÇáÇáÒ»µã,Çå³ýϵͳÀ¬»ø¡ý
ͼƬÅúÁ¿ÏÂÔØÆ÷
¡ýÅúÁ¿ÏÂÔØͼƬ,ÃÀŮͼ¿â¡ý
  ÍøÕ¾ÁªÏµ: qq:121756557 email:121756557@qq.com  ITÊýÂë