有结果未必是成功,但是没有结果一定是失败。
每日一练
将摄氏度转换成华氏摄氏度
Celsius = float(input("Enter a degree in Celsius:"))
fahren = (9/5) * Celsius + 32
print('%.1fCelsius is %.1fFahren'%(Celsius,fahren))
计算圆柱的面积和体积
import numpy as np
radius =float(input('radius is :'))
length =float(input('length is :'))
area = radius * radius * np.pi
volume = area * length
print('The area is %.2f The volume is :%.2f'%(area,volume))
将英尺数转换为米数
feet = float(input('Enter a value for feet:'))
meters = feet * 0.305
print('%.1f feet is %f meters'%(feet,meters))
(科学:计算能量)计算将水从初始温度加热到最终温度所需要的能量
amount = float(input('Enter the amount of water in kilograms:'))
initial = float(input('Enter the initial temperature:'))
final = float(input('Enter the fial teperature:'))
energy = amount * (final - initial) * 4184
print('The energy needed is :%f'%(energy))
金融应用程序:计算利息 编写一个读取差额和年利率,然后显示下月要付利息的程序
balance = float(input('Enter balance rate(e.g.,3for %3):'))
interest = float(input('Enter interest rate:'))
lixi = balance * (interest / 1200)
print('The intterest is :%f'%(lixi))
加速度:编写一个程序 求平均加速度
v0 = float(input('Enter v0 is:'))
v1 = float(input('Enter v1 is:'))
t = float(input('Enter t is:'))
a =(v1 - v0) / t
print('The average acceleration is %f'%(a))
金融应用程序:复利值 编写一个程序,提示用户键入每月存款数然后显示六个月的账户总额
month = 0
monthly = float(input('Enter the monthly saving amount:'))
for i in range(6):
month = (monthly + month) * (1 + 0.05/12)
print('After the sixth month , the account value is:%f'%(month))
对一个整数中的个位数字求和
number = input('enter a number between 0 and 1000 :')
bw = int(number[0])
sw = int(number[1])
gw = int(number[2])
sum = bw + sw + gw
print('The sum of the digits is :%r'%sum)
####邮箱登录,第一次输入密码,如果输入错误,第二次需要验证码,
count = 0
import random
user = input ('输入账户:')
password = input('输入密码:')
if user == '1679019041' and password == '123456789':
print('登陆成功!')
else:
print('账户或密码错误,再次输入!')
for i in range(3):
ran = random.randint(1000,9999)
user = input ('输入账户:')
password = input('输入密码:')
print(ran)
num = int(input('验证码'))
if num == ran:
if user == '1679019041' and password == '123456789':
print('登陆成功!')
break
else:
if user != '1679019041' or password != '123456789':
print('账户或密码错误,再次输入!')
count+=1
else:
print('验证码错误重新输入!')
count+=1
if count == 3 :
print('sb账户已锁定')