Python-1-Day

 

C = float(input("Enter a degree in Celsius:"))
F = (9/5) * C + 32
print("{0} Celsius is {1} Fahrenheit".format(C,F))

Enter a degree in Celsius:43
43.0 Celsius is 109.4 Fahrenheit

import math
R,H = eval(input("Enter the radius and length of a cylinder: "))
area = R * R * math.pi
volume = area * H
print('The area is {0}'.format("%.4f"%area))
print('The volume is {0}'.format("%.1f"%volume))

Enter the radius and length of a cylinder:5.5,12
The area is 95.0332
The volume is 1140.4

feet = float(input("Enter a value for feet: "))
meters = feet * 0.305
print('{0} feet is {1} meters'.format(feet,meters) )

Enter a value for feet:16.5
16.5 feet is 5.0325 meters

 

water = float(input("Enter a value for feet: "))
initial = float(input("Enter the initial temperature: "))
final = float(input("Enter the final temperature: "))
energy = water * (final - initial) * 4184
print('The energy needed is {0}'.format(energy))

Enter a value for feet: 55.5
Enter the initial temperature: 3.5
Enter the final temperature: 10.5
The energy needed is 1625484.0

balance,interestrate = eval(input("Enter balance and interest rate (e.g., 3 for 3 %):"))
interest = balance * (interestrate/1200)
print('The interest is {0}'.format("%.5f"%interest))

Enter balance and interest rate (e.g., 3 for 3 %):1000,3.5
The interest is 2.91667


v0,v1,t = eval(input("Enter v0,v1,and t:"))
a=(v1-v0)/t
print('The averager acceletion {0}'.format("%.4f"%a))

Enter v0,v1,and t:5.5,50.9,4.5
The averager acceletion 10.0889

from _pydecimal import Decimal
amount = Decimal(input("Enter the monthly saving amount : "))
amount1 = Decimal(0)
for i in range(6):
amount1 = (amount+amount1) * Decimal(1 +0.00417)
print('After the sixth month,the account value is {0}'.format("%.2f"%amount1))

Enter the monthly saving amount : 100
After the sixth month,the account value is 608.82

number = float(input("Enter a number between 0 and 1000 : "))
ge = int(number % 10)
shi = int(number // 10 % 10)
qian = int(number // 100)
digits = ge + shi + qian
print('The sum of the digits is {0}'.format(digits))

Enter a number between 0 and 1000 : 999
The sum of the digits is 27


posted @ 2019-07-30 21:44  DevonL  阅读(226)  评论(2编辑  收藏  举报