- Python Programming with Raspberry Pi
- Sai Yamanoor Srihari Yamanoor
- 125字
- 2021-07-02 23:48:44
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.
推薦閱讀
- 反饋系統:多學科視角(原書第2版)
- 西門子S7-200 SMART PLC從入門到精通
- 網上生活必備
- Blockchain Quick Start Guide
- 程序設計語言與編譯
- Matplotlib 3.0 Cookbook
- Hands-On Machine Learning with TensorFlow.js
- 永磁同步電動機變頻調速系統及其控制(第2版)
- Docker High Performance(Second Edition)
- 運動控制器與交流伺服系統的調試和應用
- LAMP網站開發黃金組合Linux+Apache+MySQL+PHP
- Mastering ServiceNow Scripting
- 基于神經網絡的監督和半監督學習方法與遙感圖像智能解譯
- 精通LabVIEW程序設計
- INSTANT VMware vCloud Starter