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

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.

主站蜘蛛池模板: 迭部县| 喀喇沁旗| 犍为县| 成武县| 务川| 阿克陶县| 婺源县| 左贡县| 嘉禾县| 连山| 伊川县| 灵台县| 马关县| 岢岚县| 淮南市| 阜新| 来宾市| 交口县| 孟连| 黔江区| 通化县| 永宁县| 奉贤区| 兴和县| 惠来县| 榆中县| 永修县| 通化县| 滦平县| 任丘市| 视频| 甘南县| 慈溪市| 北海市| 资中县| 香河县| 尉犁县| 申扎县| 抚松县| 巩留县| 时尚|