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

等待用户输入

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

实例(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))

结果:

猜你喜欢

转载自www.cnblogs.com/aszeno/p/9146046.html