官术网_书友最值得收藏!

Printing variables

How can you tell what the value of a variable is? One way is to print the value out to the console. To print the value of a variable, you first type the keyword print, then the name of the variable between parentheses (). The full syntax is:

print (<variable>)

For example, we can check the value assigned to foo with the following code:

foo = "bar"
print (foo)

The first line of code creates a variable named foo and assigns it the string value "bar". The second line prints the value of the foo variable. This means bar will be printed to the console:

Where does the print keyword come from? What's a keyword? Why do we use parentheses when using print? These questions will be answered in the Functions section of this chapter.
主站蜘蛛池模板: 鄂尔多斯市| 南溪县| 泌阳县| 瑞安市| 喀喇沁旗| 神木县| 通许县| 五常市| 栖霞市| 枝江市| 苏尼特左旗| 桐庐县| 安达市| 依安县| 唐山市| 康平县| 丹阳市| 丰台区| 若尔盖县| 绿春县| 正阳县| 徐州市| 邯郸市| 安康市| 高唐县| 民勤县| 那坡县| 综艺| 宣城市| 海伦市| 泗阳县| 湖州市| 黑山县| 饶阳县| 专栏| 广昌县| 茌平县| 拉萨市| 托克托县| 门头沟区| 青阳县|