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

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.

主站蜘蛛池模板: 沙湾县| 喀喇沁旗| 中山市| 星座| 安塞县| 卢龙县| 临沂市| 洛南县| 横峰县| 嘉峪关市| 遵化市| 林口县| 汤阴县| 屏东市| 西贡区| 通州区| 兰溪市| 苏尼特左旗| 景德镇市| 金华市| 漾濞| 湘乡市| 莒南县| 隆化县| 丹凤县| 内乡县| 吐鲁番市| 白河县| 合肥市| 太湖县| 石台县| 龙游县| 临武县| 洪江市| 临武县| 慈利县| 徐州市| 原阳县| 钟祥市| 大理市| 孝感市|