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

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.

主站蜘蛛池模板: 毕节市| 绥滨县| 慈利县| 黄石市| 南汇区| 托里县| 鲁山县| 东阳市| 黎城县| 辉南县| 台南市| 文登市| 汝南县| 秦安县| 辽宁省| 上思县| 尚志市| 泾阳县| 芮城县| 怀化市| 陈巴尔虎旗| 民和| 洛扎县| 琼结县| 耒阳市| 柳江县| 板桥市| 红河县| 津南区| 南皮县| 镇宁| 莱阳市| 安徽省| 德钦县| 汉源县| 沭阳县| 石台县| 武隆县| 普宁市| 海门市| 涡阳县|