Python学习(一)

今天是我学习python的第一天,感觉不错,我一口气看了python简明教程的1到8章,哈哈,主要是因为前面的东西都是自己知道的,所以看得非常的快,呵呵呵,当然,我在看得时候还是写了几行代码,写了这么几行代码,我觉得python真的是一种很爽的东西,哈哈哈哈,好简洁啊,而且还不用受限于平台,也就是说,只要我们的代码中没有用到依赖于平台的东西的话,那么就可以把程序一个字都不改的放在不同的操作系统中使用,例如linux或者windows,更或者mac os,再在或者unix………………等等等等,和java一样的爽,虽然我觉得我可能学习java更有前途,但是不知道为什么,我一接触到python的时候,我发觉我的兴趣远远的超过了java:) 下面我把我今天联系的代码贴出来,呵呵,大家不要笑噢:)还有一点,我发现python好像不能用中文的注释,那样会出错


---------------------------------------------------------------------------
#!c:/python

number = 23
running = True

while running:
guess = int(raw_input('Enter an integer : '))

if guess == number:
print 'Congratulations, you guessed it.' 
running = False # this causes the while loop to stop
elif guess < number:
print 'No, it is a little higher than that' 
else:
print 'No, it is a little lower than that' 
else:
print 'The while loop is over.' 
# Do anything else you want to do here

print 'Done' 
---------------------------------------------------------------------------
#!c:/python
#print the function's document string of printMax

def printMax(x, y):
''Prints the maximum of two numbers.
The two values must be integers.''

x = int(x) # convert to integers, if possible
y = int(y)

if x > y:
print x, 'is maximum'
else:
print y, 'is maximum'

printMax(3, 5)
print printMax.__doc__ 
---------------------------------------------------------------------------
#!c:/python

def CallCustomFunction(a,b):
print "the a=" + str(a) + ",the b=" + str(b)
print "this is CustomFunction"
strUserEnter = raw_input("Please enter a string:" )
print "user type is :"  + strUserEnter
a = a + 1
b = b + 1

a = 1
b = 1
CallCustomFunction(a,b)
print "a=" + str(a) + ",b=" + str(b)
---------------------------------------------------------------------------
#!c:/python

for i in range(1,10):
print str(i) + "/t|"
else:
print "the for loop is over"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值