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

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.

主站蜘蛛池模板: 舒城县| 抚宁县| 会东县| 旌德县| 来安县| 亳州市| 邹平县| 奉贤区| 大埔区| 龙泉市| 巧家县| 沙田区| 依兰县| 曲周县| 黔江区| 南雄市| 南靖县| 长岛县| 玉门市| 万荣县| 泸定县| 赤水市| 水城县| 岳阳县| 鸡西市| 道真| 开远市| 宜君县| 中方县| 巴彦县| 志丹县| 巴林右旗| 古蔺县| 灌南县| 乐亭县| 大庆市| 波密县| 鄂尔多斯市| 界首市| 磐安县| 长阳|