• 练习:等待用户输入input()


    等待用户输入

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

    实例(Python 3.0+)

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

    习题10:

    print("习题10:那是什么?")
    
    tabby_cat = "	I'm tabbed in." #	 表示缩进
    persian_cat = "I'm split
    on a line." #句子指向变量,
    表示换行
    backslash_cat = "I'm \ a \ cat."  # \打印出一个
    
    fat_cat = '''
    I' ll do a list:
    	* Cat food
    	* Fishies
    	* Catnip
    	* 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))

    结果:

  • 相关阅读:
    VC++导入导出类
    SVN操作手册
    stdcall与cdecl的区别
    VC++编译MPIR 2.7.0
    zabbix 监控 WEB 应用性能
    zabbix 常用监控模板
    zabbix 自定义 windows 监控项
    zabbix 自定义 nginx 监控模板
    zabbix agent 自定义 UserParameter
    zabbix python 微信告警脚本
  • 原文地址:https://www.cnblogs.com/aszeno/p/9146046.html
Copyright © 2020-2023  润新知