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

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.

主站蜘蛛池模板: 政和县| 威远县| 冷水江市| 敦化市| 五莲县| 霸州市| 巢湖市| 桂林市| 长治市| 阿图什市| 沾益县| 项城市| 红原县| 盐源县| 凌海市| 平江县| 醴陵市| 满洲里市| 莆田市| 蒙阴县| 开江县| 延吉市| 闵行区| 二连浩特市| 崇文区| 喜德县| 敦煌市| 巨鹿县| 景洪市| 龙胜| 巫山县| 浮梁县| 万安县| 双江| 安远县| 黔江区| 宜良县| 五常市| 云阳县| 日土县| 柏乡县|