python细节温习

#缩进是python的灵魂,缩进不对就会报错,
#python完全是通过缩进组织程序,而不是通过括号
#在python注释多行用三个单引号‘’‘

print("-----------我爱我自己的瞌睡------------")
temp = input('不妨猜一下我的心情是哪一个数字:')
guess =int(temp)
if guess ==8:
    print('卧槽,你是我心目中的蛔虫吗?!')
    print('哼,猜中了也米有奖励!')
else:
    print("猜错了,我现在的心情是8!")
print("游戏结束,不玩啦")

import turtle
turtle.showturtle()
turtle.write('zhoujian')
turtle.forward(300)
turtle.color('red')
turtle.left(90)
turtle.forward(300)
turtle.goto(0,50)
turtle.goto(0,0)
turtle.penup()
turtle.goto(0,300)
turtle.pendown()
turtle.circle(100)


for i in range(5):
    
    print(str(i)+ ":::")
    
for j in range(5,9):
    
    print(str(j)+ "::   ")
for k in range(0,10,2):
    print(k)
  

import random
for i in range(5):
    print(random.randint(1,10))
import sys,os,math 
from random import*
print(randint(1,2))
#使用from加上关键字之后是模块的名字或者import关键字和*
#调用random模块的函数不需要random.的前缀,但是不太提倡

import sys
while True:
    print('Type exit to exit.')
    response = input()
    if response == 'exit':
        sys.exit()
    print('You typed '+response+ '.')

猜你喜欢

转载自blog.csdn.net/zjguilai/article/details/89220916