首页 > 其他 > 详细

习题10:等待用户输入input()

时间:2018-06-06 17:35:08      阅读:280      评论:0      收藏:0      [点我收藏+]

等待用户输入

执行下面的程序在按回车键后就会等待用户输入:

实例(Python 3.0+)

#!/usr/bin/python3 input("\n\n按下 enter 键后退出。")

 

习题10:

print("习题10:那是什么?")

tabby_cat = "\tI‘m tabbed in." #\t 表示缩进
persian_cat = "I‘m split\non a line." #句子指向变量,\n表示换行
backslash_cat = "I‘m \\ a \\ cat."  # \\打印出一个\

fat_cat = ‘‘‘
I‘ ll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
‘‘‘
#3个单引号等同于3个双引号

print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)

print("my_age %s"%27)
print(my_age %s%27)

结果:

技术分享图片

习题11:

 

‘‘‘
print("How old are you?")

age = int(input("输入你的年纪:"))

print("How tall are you ?")

height = int(input("请输入你的身高:"))

print("How much do you weight?")

weight = int(input("请输入你的体重:"))

print("so,you‘re %r old,%r tall and %r weight"%(age,height,weight))
‘‘‘
print("习题11/12:提问,提示别人!")

age = int(input("How old are you?:"))

height = int(input("How tall are you ?:"))

weight = int(input("How much do you weight?:"))

print("so,you‘re %r old,%r tall and %r weight"%(age,height,weight))

结果:

技术分享图片

 

习题10:等待用户输入input()

原文:https://www.cnblogs.com/aszeno/p/9146046.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!