Python语法基础

时间:2021-06-30 10:43:32
# coding=utf-8import random

teacher = (1 < 3) and (2 > 5)print (teacher)

index = random.randint(1, 10)print (index)

a = True * Trueprint ("a = " + str(a))

b = 5print float(b)

print "type = " + str(type(b))

print isinstance(a, float)

c = 10c %= 2print "c = " + str(c)

d = 5;print d or c

x, y = 4, 5

print x if x < y else y

jsoassert 3 < 4

menber = ['葫芦娃',3.14,'mm','dd','hh']for i in menber:    print(i,len(menber))

for j in range(0,10):     print(-j)

menber.extend(['1','2'])menber.insert(1,'gggg')print menber

print ('------------------Edwin-------------------')temp = input("不妨猜一下我现在心里想的是哪个数字:")guess = int(temp)while guess != 8:    temp = input("不妨猜一下我现在心里想的是哪个数字:")    guess = int(temp)    if guess == 8:        print ("我草,你是我心里的蛔虫吗?")    else:        if guess > 8:            print ("哥,大了大了~ ~");        else:            print ("嘿,小了!小了~~!")print ("游戏结束,不玩啦")