python字符串转浮点数_Python | 打印不同的值(整数,浮点数,字符串,布尔值)...
python字符串轉(zhuǎn)浮點(diǎn)數(shù)
In the given example, we are printing different values like integer, float, string and Boolean using print() method in python.
在給定的示例中,我們使用python中的print()方法打印不同的值,例如整數(shù),浮點(diǎn)數(shù),字符串和布爾值。
Program:
程序:
# printing integer value print(12) # printing float value print(12.56) # printing string value print("Hello") # printing boolean value print(True)Output
輸出量
12 12.56 Hello TrueArithmetic operations inside the print() on values
在print()中對(duì)值進(jìn)行算術(shù)運(yùn)算
# adding and printing integer value print(12+30) # adding and printing float value print(12.56+12.45) # adding and printing string value print("Hello"+"World") # adding and printing boolean value print(True+False)Output
輸出量
42 25.009999999999998 HelloWorld 1Printing different types of variables
打印不同類型的變量
# variable with integer value a=12 # variable with float value b=12.56 # variable with string value c="Hello" # variable with Boolean value d=True# printing all variables print(a) print(b) print(c) print(d)Output
輸出量
12 12.56 Hello TruePrinting different types of variables along with the messages
打印不同類型的變量以及消息
# variable with integer value a=12 # variable with float value b=12.56 # variable with string value c="Hello" # variable with Boolean value d=True# printing values with messages print("Integer\t:",a) print("Float\t:",b) print("String\t:",c) print("Boolean\t:",d)Output
輸出量
Integer : 12 Float : 12.56 String : Hello Boolean : TruePrinting different types of variables with messages and converting them to string using "str()" function
使用消息打印不同類型的變量,并使用“ str()”函數(shù)將其轉(zhuǎn)換為字符串
# variable with integer value a=12 # variable with float value b=12.56 # variable with string value c="Hello" # variable with Boolean value d=True# printing values with messages print("Integer\t:"+str(a)) print("Float\t:"+str(b)) print("String\t:"+str(c)) print("Boolean\t:"+str(d))Output
輸出量
Integer :12 Float :12.56 String :Hello Boolean :True翻譯自: https://www.includehelp.com/python/printing-different-values-integer-float-string-boolean.aspx
python字符串轉(zhuǎn)浮點(diǎn)數(shù)
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的python字符串转浮点数_Python | 打印不同的值(整数,浮点数,字符串,布尔值)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c++freopen函数_使用示例的C语
- 下一篇: java 系统自动检测_如何在Java中