1、算數運算子
2、比較運算子
3、邏輯運算子
4、賦值運算子
5、成員運算子
6、while迴圈
a=input("number:")
b=input("
number:")
print(int(a)+int(b))
(type(a))
content=input("
請輸入數字:")
if content == '1'
:
print("
你好啊!")
else
:
print("
hello world
")
number=88content = int(input("請輸入數字:
"))#
預設字串,需要強制轉換
if content >number :
print("
你太大了!")
elif content
print("
你太小了!")
else
:
print("
恭喜你猜中了!
")
#whlie迴圈
#1.continue和break兩者的用法
while
true:
content=input("
請輸入一句話,(按q可以退出迴圈!):")
if content=='q'
:
continue
#break
print(content)
#7、格式輸出2.輸出1-10之間的所有數,除4以外
count=1
while count <=10:
if count==4:
count = count + 1
continue
(count)
count=count+1
#8、運算子%s 佔位符,佔位字串
#%d 佔位符,佔位數字
name="
華少年"
age='22'
hobby="
看書、運動
"location="家裡"
print("
乙個叫"+name+"
的"+age+"
歲年輕小伙,喜歡在
"+location+hobby+"哦"
)print("
乙個叫%s的%s歲年輕小伙,喜歡在%s哦
" %(name,age,hobby))
#9、編碼**次冪
#% 餘數
#// 整除
#/ 普通除
#and 表示並且
#or 表示或者
#not 非真既假,非假既真,表取反
#優先順序:()> not > and > or
#x or y:如果x為0,返回y;如果x為非零,返回x;例:1 ro 2結果為1;0 or 2 結果為2
#x and y,與 or 相反。0 and 任何數為0;非零 and 非零任意數為大後者。
#ascll碼: 8位,1位元組
#gbk碼: 16位,2位元組
#unicode碼: 32位,4位元組
#utf-8: 可變長編碼
#英文:8位
#歐文:16位
#漢字:24位
Python基礎語法第二天
print 1 1 2 print 1 1 0 print 1 1 1 print 1 1 print 5 2 1.0 2.5 的結果時浮點數floatprint 5 2 5除以2的餘數 1 1 print 8 3 8 3 8 3 2 2 2應用1 判斷整數的奇偶性 根據整數對2取餘的結果是否是0來...
Python基礎第二週第二天
導言 通過上一周的學習,我們對python這個新朋友有了乙個基本的了解和認識,那麼今天讓我們來深入了解一下 python物件和物件導向的高階特性 課程小節 1 python的魔法功能,魅力之所在,讓 量更少1 2 python的魔法功能,魅力之所在,讓 量更少2 3 看python如何靈活應用經典設...
Android基礎第二天
網路訪問 寫sd卡 讀sd卡 this.getfilesdir getpath 返回乙個資料夾 data data 包名 files 使用this.getcachedir getpath 用api獲取sdcard的路徑 不同手機sdcard資料夾位置不同 environment.getexterna...