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

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.

主站蜘蛛池模板: 偃师市| 东阳市| 北流市| 高淳县| 岳阳县| 理塘县| 屯门区| 安仁县| 英德市| 涪陵区| 汉川市| 天门市| 高唐县| 津市市| 泰宁县| 武平县| 遂川县| 突泉县| 威信县| 宕昌县| 来宾市| 饶阳县| 托克托县| 琼海市| 伊宁市| 施甸县| 嫩江县| 大理市| 青冈县| 永泰县| 封开县| 陇南市| 乌拉特中旗| 资阳市| 亳州市| 略阳县| 驻马店市| 玉田县| 鹤壁市| 隆德县| 临桂县|