python學習之路

2022-09-19 10:42:10 字數 3157 閱讀 3747

x = 1+2+3+4

print(x)

print(x*5)

y = x*5

print(y+100-45+2)

print('泰哥泰哥,我是小弟')

print('泰哥泰哥,我是三弟小妹')

t-t = 2

3t_t = 23

*r = 4

_ = 'fdsa'

___ = 4

%- = 'fdsa'

2w = 5

qwe-r = 'wer'

kfdsdlafhsdakfhdsakdfjkhsdakf = '太白'

print(名字)

ageofoldboy = 56

numberofstudents = 80

#下劃線

age_of_oldboy = 56

number_of_students = 80

age1 = 12

age2 = age1

age3 = age2

age2 = 100

age3 = 5

print(age1,age2,age3) #12, 100 ,100

#12,12,12,

#12,100,12

#100,100,100,

print(100,type(100))

print('100',type('100'))

print(1)

print("jsdfdsfsadl;fjdsal;j")

print("i'm a teacher")

a = '泰哥'

b = '小二'

c = a + b

print(c)

print('泰哥' + '小二' +'貨')

print('堅強'*8)

msg = """

今天我想寫首小詩,

歌頌我的同桌,

你看他那烏黑的短髮,

好像乙隻炸毛雞。

"""#print(msg)

print(true,type(true))

print('true',type('true'))

name = input('請輸入你的名字:')

age = input('請輸入你的年齡:')

print('我的名字是'+name,'我的年齡'+age+'歲')

#第一種:

if 4 > 5 :

print('我請你喝酒')

print('喝什麼酒')

#第二種:

if 4 > 5:

print('我請你喝酒')

else:

print('喝什麼酒')

#多選:

num = input('請輸入您猜的數字:')

if num == '1':

print('一起抽菸')

elif num == '2':

print('一起喝酒')

elif num == '3':

print('新開了一家,走看看')

else:

print('你猜錯了.....')

score = int(input("輸入分數:"))

if score > 100:

print("我擦,最高分才100...")

elif score >= 90:

print("a")

elif score >= 60:

print("c")

elif score >= 80:

print("b")

elif score >= 40:

print("d")

else:

print("太笨了...e")

name = input('請輸入名字:')

age = input('請輸入年齡:')

if name == '小二':

if age == '18':

print(666)

else:

print(333)

else:

print('錯了....')

#while

print('111')

while true:

print('我們不一樣')

print('在人間')

print('癢')

print('222')

#從1--100

count = 1

flag = true

#標誌位

while flag:

print(count)

count = count + 1

if count > 100 :

flag = false

count = 1

while count <= 100:

print(count)

count = count + 1

count = 1

sum = 0

while count <= 100:

sum = sum + count

count = count + 1

print(sum)

#break

'''print('11')

while true:

print('222')

print(333)

break

print(444)

print('abc')

count = 1

while true:

print(count)

count = count + 1

if count > 100:break

print(111)

count = 1

while count < 20 :

print(count)

continue

count = count + 1

count = 0

while count <= 100 :

count += 1

if count > 5 and count < 95:

continue

print("loop ", count)

print("-----out of while loop ------")

Python學習之路

python 十分鐘入門 python 菜鳥教程 pycharm安裝numpy python 檔案讀取 with open xml path,r as fr content fr.read python讀取檔案時提示 unicodedecodeerror gbk codec can t decode...

python學習之路

簡單理解下,yield可以先看作 return 直接返回某個值,返回之後程式就不再往下執行了。看做return之後再把它看做乙個是生成器 generator 的一部分 帶yield的函式才是真正的迭代器 def foo print starting.while true res yield 4pri...

python學習之路

1 讀純文字檔案 file open file.close 做好前置準備,以及首尾語句 1 file open chinese.txt mode r encoding utf 8 content file read print content file close 2 寫純文字檔案 引數mode r...