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))
相关文章推荐
- python dict.get()和dict['key']的区别详解
- python中set常用操作汇总
- 浅谈python中set使用
- 详解Python操作RabbitMQ服务器消息队列的远程结果返回
- python开发实习面试感悟
- Python入门自学笔记20160628
- python-操作hive
- Install hunspell with python on Ubuntu
- python正则表达式
- 使用cx_Freeze 将python3代码打包成.exe程序
- 10W -python
- 关于Python文件读写及访问方式
- 利用Python实现快速算法排序
- 详解Python操作RabbitMQ服务器消息队列的远程结果返回
- 浅谈python中set使用
- python中set常用操作汇总
- python dict.get()和dict['key']的区别详解
- 浅谈Python 集合(set)类型的操作――并交差
- 全面了解Python环境配置及项目建立
- Python列出一个文件夹及其子目录的所有文件