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

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.

主站蜘蛛池模板: 前郭尔| 衡水市| 蒲城县| 鹿邑县| 楚雄市| 张家界市| 新昌县| 金门县| 营山县| 治多县| 汨罗市| 和龙市| 巴林右旗| 类乌齐县| 衡东县| 翼城县| 通江县| 沈阳市| 弥勒县| 新余市| 吉林省| 商城县| 东平县| 中宁县| 宜春市| 石景山区| 肃南| 开化县| 巴彦县| 洪湖市| 安阳县| 米泉市| 吐鲁番市| 中牟县| 富蕴县| 胶南市| 舞阳县| 西宁市| 克山县| 泌阳县| 梧州市|