Python Exercises(2)

    xiaoxiao2022-07-04  212

    1、

                                

    (1)Why are you using the variable named 'snow'?(That's actually not a variable: it is just a string with the word snow in it. A variable wouldn't have the single-quotes around it.)

    (2)Can I use single-quotes or double-quotes to make a string or do they do different things?(In Python either way to make a string is acceptable, although typically you'll use single-quotes for any short strings like 'a' or 'snow'.)

     

    2、

               

    (1)Why do I have to put quotes around "one" but not around True or False?(Python recognizes True and False as keywords representing the concept of true and false. If you put quotes around them then they are turned into strings and won't work.)

     

    3、

                         

    (1)Why do I get an error when I put spaces between the three double-quotes?(You have to type them like """ and not " " ", meaning with no spaces between each one.)

     

    4、

                                                        

     

    5、

                      

    (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 to an integer using int().

    (2)I put my height into raw input like this input("6'2") but it doesn't work?(You just need to type it directly into your terminal.)

     

    6、

                          

    (1)How come I get SyntaxError:invalid syntax whenever I run pydoc?(You aren't running pydoc from the command line; you're probably running it from inside python. Exit out of python first.)

    (2)Why does my pydoc not pause like yours does?(Sometimes if the help document is short enough to fit on one screen then pydoc will just print it.) 

    (3)When I run pydoc I get more is not recognized as an internal.?(Some versions of Windows do not have that command, which means pydoc is broken for you. You can just online for Python Documentation when you need it.)

    (4)Why can't I do print("How old are you?", input())?(You can, but then the result of calling input() is never saved to a variable, and it'll work in a strange way.)

    最新回复(0)