美文网首页
笨办法学python第11课

笨办法学python第11课

作者: 3ab9db71c244 | 来源:发表于2018-09-06 15:10 被阅读21次
    print("how old are you?", end = '  ')  #用end = ' '的意义在于,把age = input()放到同一行
    age = input()
    print('how tall are you?', end = ' ')  
    height = input()
    print("how much do you weigh?", end = ' ')
    weight = input()
    print(f"so, you're {age} old, {height} tall and {weight} heavy.") #input的age也可以成为打印字符串的变量
    
    运行结果:
    /Users/tongshiba/PycharmProjects/ex3/test11.py
    how old are you?29
    how tall are you?180
    how much do you weigh?18
    so ,you're 29 old, 180 tall and 18 heavy.
    Process finished with exit code 0
    
    
    
    Study Drills练习题
    1. Go online and find out what Python’s input does.
    
    找到input的用法
    
    2. Can you find other ways to use it? Try some of the samples you find.
    
    not yet
    
    3. Write another “form” like this to ask some other questions
    
    not yet
    
    Common Student Questions常见问题:
    1.How do I get a number from someone so I can do math? 
    
    That’s a little advanced, but try x = int(input()), which gets the number as a string from input(), then converts it to an integer using int(). 
    
    2.I put my height into raw input like this input("6'2") but it doesn’t work. 
    
    Don’t put your height in there; type it directly into your Terminal. First, go back and make the code exactly like mine. Next, run the script, and when it pauses, type your height in at your keyboard. That’s all there
    is to it.

    相关文章

      网友评论

          本文标题:笨办法学python第11课

          本文链接:https://www.haomeiwen.com/subject/tuwbwftx.html