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

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.

主站蜘蛛池模板: 乐至县| 白玉县| 闽侯县| 玛曲县| 本溪| 图片| 康保县| 江城| 南华县| 凤台县| 营口市| 册亨县| 南溪县| 诏安县| 阳曲县| 华亭县| 乐至县| 民权县| 南和县| 新津县| 邯郸县| 贵州省| 凉山| 上犹县| 平罗县| 乌拉特中旗| 崇左市| 唐海县| 敦化市| 泾阳县| 沁源县| 庆安县| 错那县| 新平| 盘锦市| 临江市| 诸暨市| 潢川县| 邹城市| 即墨市| 新建县|