python基础练习(六)_八进制

line = "After fresh rain in mountains bare "
print(line.title())

python基础练习(六)_八进制_02

python基础练习(六)_八进制_03

a = float(input("输入三角形第一条直角边长:"))
b = float(input("输入三角形第二条直角边长:"))
area=(a*b)/2
print("直角三角形的面积为:{:.1f}".format(area))

python基础练习(六)_八进制_04

python基础练习(六)_十六进制_05

num = eval(input("输入数字:"))
print("对应的二进制数:{0:b}\n八进制数:{0:o}\n十六进制数:{0:X}".format(num))#注意0

python基础练习(六)_二进制数_06

python基础练习(六)_十六进制_07

import turtle
turtle.color('black','yellow')
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()

python基础练习(六)_十六进制_08

python基础练习(六)_八进制_09

def judge_year(year):
if (year%4==0 and year%100!=0) or year%400==0:
print(year,"年是闰年")
else:
print(year,"年不是闰年")#有空格
year = eval(input("请输入年份:"))
judge_year(year)

python基础练习(六)_八进制_10

python基础练习(六)_二进制数_11

python基础练习(六)_二进制数_12

fi = open("score.csv","r")
fo = open("avg-score.txt","w")
ls = []
x = []
sum = 0
for row in fi:
ls.append(row.strip("\n").split(","))
for line in ls[1:]:
for i in line[1:]:
sum+=int(i)
avg=sum/3
x.append(avg)
sum=0
fo.write("语文:{:.2f}\n数学:{:.2f}\n英语:{:.2f}\n物理:{:.2f}\n科学:{:.2f}\n".format(x[0],x[1],x[2],x[3],x[4]))
fi.close()
fo.close()

python基础练习(六)_二进制数_13