习题11:提问

时间:2022-06-05
本文章向大家介绍习题11:提问,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

现在要做的是把数据读到你的程序里去,不理解?不要紧,跟着做几个练习就会明白

一般软件做的事情主要就是下面几条:

1.接受人的输入

2.改变输入

3.打印出改变的输入

代码如下:切记不要复制粘贴,每一个练习,都需要自己手动去敲代码,这样才能明白

# coding: utf-8
__author__ = 'www.py3study.com'
print("How old are you?")
age = input()
print("How tall are you?")
height = input()
print("How much do you weight?")
weight = input()
print("So,you're {} old, {} tall and {} heavy.".format(age, height, weight))

应该看到的结果

How old are you? 18 How tall are you? 180 How much do you weight? 130 So,you're 18 old, 180 tall and 130 heavy.

常见问题

如何读取用户输入的数字进行计算?

可以使用x = int(input()),它会把用户输入的字符串转换为整数