python Days1

python代码编写使用英文输入法

控制台的读取和输入:

input输入进去的是字符串

eval

在jupyter用shift+tab跳出解释文档

运算符:

+:加

-:减

*:乘

/:除

//:整除

**:指数幂

%:取余

增强型赋值运算:

+=:自加

-=:自减

*=:自乘

/=:自除

代码:

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

代码:

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

代码:

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

代码:

water=float(input('Enter the amount of water in kilograms:'))
initialtemperature=float(input('Enter the initial temperature:'))
finaltemperature=float(input('Enter the final temperature:'))
Q = water * (finaltemperature - initialtemperature) * 4184
print("The energy needed is ",Q)

代码:

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))

代码:

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

代码:

number=float(input("Ener the monthly saving amount :"))
number1=0
for i in range(6):
    number1=(number+number1) * (1 + 0.00417)
print("After the sixth month,the account value is {0}".format("%.2f"% number1))

代码:

 number=float(input("Enter a number between 0 and 1000:"))
bai=int(number/100)
shi=int(number/10%10)
ge=int(number%10)
he=bai+shi+ge
print("The sum of the digits is ",he)

体会:

通过初时Python以及对他的语言元素的认识,对于python有了很深的印象

转载于:https://www.cnblogs.com/huangchuan/p/11272641.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值