糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > python定义整数_Python | 程序定义一个整数值并打印

python定义整数_Python | 程序定义一个整数值并打印

时间:2019-03-24 03:58:59

相关推荐

python定义整数_Python | 程序定义一个整数值并打印

python定义整数

Define an integer value in a variable and print it in Python.

在变量中定义一个整数值,然后在Python中打印出来。

Its very simple todeclare a variable and define an integer value to it, there is no need to define any type of keyword to make the variable an integer, we have to just assign an integer value and variable is able to store and then we can print it.

声明变量并为其定义整数值非常简单,无需定义任何类型的关键字即可使变量成为整数,我们只需分配一个整数值即可存储变量,然后我们可以打印它。

Syntax:

句法:

variable_name = value

Example:

例:

If we want to assign10to a variable named num, the statement will be:

如果我们想将10分配给名为num的变量,则该语句将为:

num = 10

Program:

程序:

# Python program to define an # integer value and print it # declare and assign an integer value num = 10# print num print "num =",num # print using formatprint "num = {0}".format(num)# assign another valuenum = 100# print num print "num =",num # print using formatprint "num = {0}".format(num)

Output

输出量

num = 10num = 10num = 100num = 100

Note:In this program, we also used format() Method to print the value as string formatted, read more about, String.format() Method.

注意:在此程序中,我们还使用format()方法将值打印为字符串格式,请阅读有关String.format()方法的更多信息。

翻译自: /python/define-an-integer-value-and-print-it.aspx

python定义整数

如果觉得《python定义整数_Python | 程序定义一个整数值并打印》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。