编程日记-Python-2015.08.30

来源:互联网 发布:华为盒子电视直播软件 编辑:程序博客网 时间:2024/06/05 04:01
今日去面试了万物花开公司,很想进入互联网行业,但是又有些犹豫不决,还是有很多问题没有想明白啊。先从Python学起吧:
切记录试试自己的程序员之路吧:
format函数到底怎么用,非常疑惑和费解。

最终,用以下程序实现了输入:weight=80 high=1.72 BMI=26.12的输出,但是其中,关于小数点后位数的控制却与在网上查到的不同,网上查到的是:print('{0:.4}'.format(BMI)),其中4代表小数点后留4位。

weight = float(raw_input())

high = float(raw_input())

BMI=weight/high**2

print(BMI)

print('{0:.4}'.format(BMI))

# -*- coding: utf-8 -*-

"""

Created on Tue Sep 01 21:11:21 2015

@author: MONKEY

已知三角形三边,求C边所对夹角大小

"""

a= float(raw_input())

b= float(raw_input())

c= float(raw_input())

delta=(a**2+b**2-c**2)/(2*a*b)

theta=math.acos(delta)*180/pi

print theta

# -*- coding: utf-8 -*-"""Created on Tue Sep 01 21:01:01 2015@author: MONKEY"""seconds = int(raw_input())hours=seconds/3600minutes= (seconds-hours*3600)/60sec=seconds%60print(hours,minutes,sec)

0 0
原创粉丝点击