您的位置:首页 > 编程语言 > Python开发

Python3从零学习(六)

2016-06-30 09:40 357 查看
# -*- coding:utf-8 -*-

year =int(input("请输入一个年份:"))

if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("是闰年")
else:
print("不是闰年")
else:
print("不是闰年")
else:
print("不是闰年")

celsius = float(input("请输入摄氏温度:"))

fahrenheit = (celsius * 1.8) + 32
print("{}摄氏温度转华氏温度为:{}".format(celsius,fahrenheit))

celsius = (fahrenheit - 32) / 1.8
print("{}华氏温度转摄氏温度为:{}".format(fahrenheit,celsius))

a = float(input("请输入边长a:"))
b = float(input("请输入边长b:"))
c = float(input("请输入边长c:"))

while (abs(a - b) >= c or c >= abs(a + b)):
c = float(input("请输入边长c:"))

s = (a + b + c) / 2

area = (s*(s-a)*(s-b)*(s-c)) ** 0.5

print("三角形的面积为:{}".format(area))

import cmath

a = float(input("输入a:"))
b = float(input("输入b:"))
c = float(input("输入c:"))

d = (b**2) - (4 * b * c)

sol1 = (-b-cmath.sqrt(b))/(2*a)
sol2 = (-b+cmath.sqrt(b))/(2*a)

print("结果为:{}和{}".format(sol1,sol2))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: