请高手用Python帮我编两个程序!

Usevariableswhereverappropriate.Also,usecommentstoincludeyournameandstudentnumberatth... Use variables wherever appropriate. Also, use comments to include your name and student number at the top of each program, as well as to clearly explain the goal of each program. Use line comments to explain the main calculations. Save your assignment programs in a directory named assignment1.
1. Write a python script (program) called timeConverter.py that asks a user to input a number. This number represents a total number of seconds. Convert this total number of seconds into a number of hours, minutes, and seconds.
Samples of what I am expecting for output are shown below:
python timeConverter.py
Enter the total number of seconds: 11839
Number of hours = 3
Number of hours = 17
Number of hours = 19
2. Write a python script called question2.py that asks a user to input a number. This number represents a total number of centimeters. Convert this total number of centimeters into a number of feet and remaining inches. Note that there are 12 inches in a foot and 2.54 centimeters in an inch.
Samples of what I am expecting for output are shown below:
python question2.py
Enter a value for centimeters: 30.48
Your input results in 1 feet and 0.0 inches.
python question2.py
Enter a value for centimeters: 2.54
Your input results in 0 feet and 1.0 inches.
python question2.py
Enter a value for centimeters: 50
Your input results in 1 feet and 7.68503937008 inches.
展开
 我来答
wwwghost1982
2010-09-28
知道答主
回答量:6
采纳率:0%
帮助的人:3.1万
展开全部
so easy, python2.4 winxp
script1:
#Converter time to hour,minuts,seconds.
print "Enter the total number of seconds: "
t_time = int(raw_input())
h = int(t_time/3600)
m = int((t_time/60)%60)
s = int(t_time%60)
print "Number of hours = %d\nNumber of minuts = %d\nNumber of seconds = %d"%(h,m,s)

script2:
print "Enter a value for centimeters: "
cen = float(raw_input())
feet = (cen/2.54)/12
inch = (cen/2.54)%12
print "Your input results in %d feet and %f inches."%(feet,inch)
stablish
2010-09-28 · TA获得超过8784个赞
知道大有可为答主
回答量:5161
采纳率:50%
帮助的人:5032万
展开全部
...... just like a newbie's homework

I REFUSE
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2010-09-28
展开全部
给他鱼
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式