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

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.
主站蜘蛛池模板: 金坛市| 甘孜| 宜川县| 贞丰县| 准格尔旗| 新竹县| 枝江市| 汶川县| 肃南| 双牌县| 杭锦旗| 广宗县| 新蔡县| 怀仁县| 农安县| 涡阳县| 连江县| 武清区| 长岛县| 龙川县| 洪湖市| 杨浦区| 通辽市| 外汇| 林西县| 宜君县| 马关县| 郯城县| 长沙市| 开化县| 永昌县| 南郑县| 鱼台县| 新乡市| 鄂温| 福贡县| 封丘县| 洪洞县| 会东县| 鹰潭市| 白玉县|