python first lesson

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print ("hello world")
hello world
>>> x=4
>>> x
4
>>> string x="this is a string"
SyntaxError: invalid syntax
>>> string x ="this is a string"
SyntaxError: invalid syntax
>>> string x= ("this is a string")
SyntaxError: invalid syntax
>>> pring x
SyntaxError: invalid syntax
>>> print x
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(x)?
>>> pring (x)
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    pring (x)
NameError: name 'pring' is not defined
>>> print (x)
4
>>> int x=5;
SyntaxError: invalid syntax
>>> int x =5 ;
SyntaxError: invalid syntax
>>> int x = 5;
SyntaxError: invalid syntax
>>> int(x)=5
SyntaxError: can't assign to function call
>>> int(x)=5
SyntaxError: can't assign to function call
>>> x=5
>>> int(a)
    
SyntaxError: invalid character in identifier
>>> x=1.0
>>> int(x)
    
SyntaxError: invalid character in identifier
>>> int(x)
1
>>> y="dad"
>>> x+y
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    x+y
TypeError: unsupported operand type(s) for +: 'float' and 'str'
>>> z=2.0
>>> x+z
3.0
>>> "thanks"+y
'thanksdad'
>>> list1=['Google', 'apple', 1997, 2000]
>>> print(list1)
['Google', 'apple', 1997, 2000]
>>> print("the third element is ",list1[2])
the third element is  1997
>>> abs(-16)
16
>>> ceil(16.7)
Traceback (most recent call last):
  File "<pyshell#29>", line 1, in <module>
    ceil(16.7)
NameError: name 'ceil' is not defined
>>> import math
>>> math.cail(16.7)
Traceback (most recent call last):
  File "<pyshell#31>", line 1, in <module>
    math.cail(16.7)
AttributeError: module 'math' has no attribute 'cail'
>>> math.ceil(16.7)
17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值