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

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.

主站蜘蛛池模板: 四平市| 洛阳市| 利川市| 阿拉尔市| 南通市| 麻江县| 于都县| 平舆县| 昌宁县| 神农架林区| 密云县| 昌吉市| 凤冈县| 洞头县| 白朗县| 双流县| 通河县| 扎囊县| 五大连池市| 张家口市| 固原市| 商丘市| 鄂温| 宁海县| 灵川县| 隆昌县| 襄垣县| 合江县| 遂川县| 防城港市| 建始县| 开封市| 天长市| 呼图壁县| 陆丰市| 天峻县| 多伦县| 呼玛县| 常山县| 红原县| 富川|