1、pycharam安装: 第一步:进入PyCharm官网,点击Tools, 第二步:点击“PyCharm”,进入安装包现在页面 第三步:点击“DOWNLOAD NOW”,根据自己需要下载匹配的操作系统的安装包 第四步:等待安装包下载完,运行即可。 第五步:选择安装目录,Pycharm需要的内存较多,建议将其安装在D盘或者E盘,不建议放在系统盘C盘。 2.输入学生成绩 score=int(input(“请输入分数”)) grade=" if score<60: grade=“不及格” elif score<80: grade=“及格” elif score<90 grade=“良好” elif score<=100: grade=“优秀” print(“分数是{0},等级是{1}”.format(score,grade)) 3.判断象限 x=int(input(“请输入x坐标”)) y=int(input(“请输入y坐标”))
if(x0 and y0):print(“原点”) elif(x0):print(“y轴”) elif(y0):print(“x轴”) elif(x>0 and y>0):print(“第一象限”) elif(x<0 and y>0):print(“第二象限”) elif(x>0 and y<0):print(“第三象限”) else: print(“第四象限”) 4、判断分数 score=int(input(“请输入一个0-100之间数字:”)) grade="" if score>100 or score<0: score=int(input(“输入错误!请输入一个在0-100之间的数字,谢谢”)) else: if score>=90: grade=“A” elif score>=80: grade=“B” elif score>=70: grade=“C” elif score>=60: grade=“D” else: grade=“E” pirint(“分数为{0},等级为{1}”.format(score,grade)) 5、while语句计算加和 num=0 sum_all=0 sun_even=0 sun_odd=0 while num<=100: sun_all+=num if num%20:sum_even+=sum else:sun_odd+=sum num +=1 print(“1-100所有数加和”,sun_all) print(“1-100所有偶数加和”,sun_even) print(“1-100所有奇数加和”,sun_odd) 6、for语句计算加和 sum_all=0 sun_even=0 sun_odd=0 for num in range(101): sum_all+=num if num%20:sun_even+=num else:sun_odd+=num print(“1-100累加总和{0},奇数和{1},偶数和{2}”.format(sun_all,sun_odd,sun_even)) 7、打印图案 for x in range(5): for y in range(5): print(x,end="\t") print() 8、九九乘法表 for m in range(1,10): for n range(1,m+1): print("{0}{1}={2}".format(m,n,(mn))),end="\t" print() 9、存储打印信息 r1=dict(name=“高小一”,age=18,salary=30000,city=“北京”) r2=dict(name=“高小二”,age=19,salary=20000,city=“上海”) r3=dict(name=“高小三”,age=20,slalry=10000,city=“深圳”) tb=[r1,r2,r3] for x in tb: if x.get(“salary”)>15000: print(x) 10.薪资输入 empnum=0 salarySum=0 salary=[] while True: s=input(“请输入员工的薪水,按q结束”)
if s.upper()=='q':
print("录入完成,退出")
break
if float(s)<0:
continue
empnum +=1
salarys.append(float(s))
salarySum +=float(s)
print(“员工数{0}”.format(empnum)) print(“录入薪资:”,salarys) print(“平均薪资{0}”.format(salarySum/empnum)) 11、薪资录入 salarySum=0 salarys=[] for i in range(4): s=input(“请输入共4人薪资,q中途退出”)
if s.upper()=='q':
print("录入完成")
break
if float(s)<0
continue
salarys.append(float(s))
salarySum +=float(s)
else: print(“已经全部录入完毕”) print(“录入薪资:”,salarys) print(“平均薪资{0}”.format(salarySum/4)) 12.绘制同心圆 import turtle t = turtle.Pen() my_colors = (“red”,“green”,“yellow”,“black”) t.width(4) t.speed(1) for i in range(10): #0 1 2 3 4 t.penup() t.goto(0,-i10) t.pendown() t.color(my_colors[i%len(my_colors)]) t.circle(15+i10) turtle.done() 13、绘制棋盘 import turtle width = 30 num = 18 x1 = [(-400,400),(-400+widthnum,400)] y1 = [(-400,400),(-400,400-widthnum)] t = turtle.Pen() t.speed(10)
for i in range(0,19): t.penup() t.goto(x1[0][0],x1[0][1]-30i) t.pendown() t.goto(x1[1][0],x1[1][1]-30i)
for i in range(0,19): t.penup() t.goto(y1[0][0]+30i,y1[0][1]) t.pendown() t.goto(y1[1][0]+30i,y1[1][1])
|