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

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.

主站蜘蛛池模板: 元江| 隆子县| 乌兰察布市| 海兴县| 祥云县| 海林市| 高要市| 徐州市| 陆河县| 固原市| 小金县| 杨浦区| 德庆县| 闻喜县| 尤溪县| 井陉县| 平湖市| 鄢陵县| 安仁县| 旺苍县| 旬邑县| 仁怀市| 永福县| 龙山县| 秭归县| 项城市| 丹凤县| 上蔡县| 阜宁县| 新昌县| 正镶白旗| 盖州市| 综艺| 民和| 龙里县| 商水县| 砀山县| 叶城县| 南丰县| 星子县| 剑河县|