Python運算符包括python
not邏輯非: not True
ide
input()與raw_input()區別(raw_input 將全部輸入都視爲字符串)
函數
#!/usr/bin/python num1 = input("Please input a number: ") num2 = input("Please input a number: ") print num1 + num2 print num1 - num2 print num1 * num2 print num1 / num2
第二種寫法(格式化輸出)code
#!/usr/bin/python num1 = input("Please input a number: ") num2 = input("Please input a number: ") print "%s + %s = %s" % (num1,num2,num1 + num2) print "%s - %s = %s" % (num1,num2,num1 - num2) print "%s * %s = %s" % (num1,num2,num1 * num2) print "%s / %s = %s" % (num1,num2,num1 / num2)