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

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.

主站蜘蛛池模板: 郴州市| 德兴市| 沙洋县| 巫溪县| 黑山县| 县级市| 宁南县| 苍山县| 万安县| 竹山县| 紫云| 滨州市| 南京市| 呼和浩特市| 五台县| 安宁市| 静海县| 凤凰县| 靖边县| 乌拉特中旗| 平远县| 巴马| 信丰县| 崇左市| 东源县| 贵港市| 永寿县| 桓仁| 右玉县| 友谊县| 郴州市| 鹰潭市| 胶南市| 佛山市| 延长县| 北宁市| 高安市| 沛县| 临城县| 长治市| 基隆市|