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

An exercise for the reader

Make use of the format() method to format a string with more than one variable.

Let's build a console/command-line application that takes inputs from the user and print it on the screen. Let's create a new file named input_test.py, (available along with this chapter's downloads) take some user inputs and print them on the screen:

    name = input("What is your name? ") 
address = input("What is your address? ")
age = input("How old are you? ")

print("My name is " + name)
print("I am " + age + " years old")
print("My address is " + address)

Execute the program and see what happens:

The input_test.py output

The preceding example is available for download along with this chapter as input_test.py.

主站蜘蛛池模板: 盱眙县| 洞头县| 郁南县| 沈阳市| 嘉义市| 高雄市| 福鼎市| 定安县| 红河县| 南通市| 陇南市| 久治县| 临泉县| 福清市| 汶上县| 水城县| 阜康市| 古蔺县| 镇宁| 五大连池市| 林甸县| 锡林郭勒盟| 武隆县| 云浮市| 长岭县| 通江县| 丰原市| 南丰县| 舟山市| 烟台市| 襄樊市| 漯河市| 广东省| 光山县| 老河口市| 新邵县| 呈贡县| 治县。| 台州市| 连南| 志丹县|