请高手用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. 展开
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. 展开
展开全部
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)
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)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询