Python Exercises(2)

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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值