PYTHON 是一種高階解釋型程式語言,以其可讀性和簡單性而聞名。
它廣泛應用於網路開發、數據分析、人工智慧、科學計算等。
如何在 python 中列印
print(“你好,世界!”)
如何用Python寫註解
# This is a single-line comment """ This is a multi-line comment """
變數與資料型別
Integer x = 10 Float y = 3.14 String name = "Alice" Boolean is_valid = True
算術運算子 - , -, , /, %, //, *
a = 10 b = 3 print(a + b) # Addition print(a - b) # Subtraction print(a == b) # Equals print(a != b) # Not equal print(a > b) # Greater than print(a < b) # Less than print(a * b) # Multiplication print(a / b) # Division print(a % b) # Modulus print(a // b) # Floor Division print(a ** b) # Exponentiation
比較運算子 - ==、!=、>、<、>=、<=
a = 10 b = 3 print(a == b) # Equals print(a != b) # Not equal print(a > b) # Greater than print(a < b) # Less than print(a >= b) # Greater than or equal print(a <= b) # Less than or equal
邏輯運算子 - and、or、not
a = 10 b = 3 print(a > 5 and b < 5) # Logical AND print(a > 5 or b > 5) # Logical OR print(!(a > 5)) # Logical NOT
條件語句 - else , if, elif
a = 10 b = 3 if a > b: print("a is greater than b") elif a < b: print("a is less than b") else: print("a is equal to b")
以上是inute 中的 Python 基礎知識的詳細內容。更多資訊請關注PHP中文網其他相關文章!