# 实验1 Python开发环境使用和编程初体验

task 1 _ 1

print('hey,u')

print('hey','u')
x,y,z = 11,45,14
print(x,y,z)

print('x = %d , y = %d, z = %d' %(x,y,z))
print('{},{},{}'.format(x,y,z))
print(f'x = {x} , y = {y} , z = {z}')

print(x)
print(y)
print(z)

print(x,end='啊')
print(y,end='啊')
print(z)

print('{:-<40}'.format('9'))
#< > ^ xxx   .format(xxx)
y1,y2,x1,x2 = 2,3,4,5
print('y1 = {},x2 = {}'.format(y1,x2))
print('x1={},y2={}'.format(x1,y2))
#输出2
print('x1 ={:^10.3f},x2 ={:3.3f}'.format(x1,x2))
print('y1 ={:10.3f},y2 ={:3.3f}'.format(y1,y2))
#输出3
print('y1 = {:<5.2f},y2 = {:>4.1f}'.format(y1,y2))
#输出4
print('x1 = {:<5.2f},x2 = {:>4.1f}'.format(x1,x2))

name1, age1 = 'Bill', 19
name2, age2 = 'Hellen', 18
title = 'Personnel Information'
print(f'{title:=^40}')
# 输出title的值，=^40指定输出宽度占40列，居中对齐，用=填充空
print(f'name: {name1:<10.1000}, age: {age1:<10}')
# 10和3分别指定数据项输出宽度
print(f'name: {name2:<1.100}, age: {age2:<3}')
print(40*'=')

r1 = eval('1+2')
print(type(r1),r1)
r2 = eval('[11,45,14]')
print(type(r2),r2)
r3 = eval(' "python" ')
print(type(r3),r3)
r4 = eval('4,6')
print(type(r4),r4)
print(f'{10:<5.}')

m,n = eval(input('输入两个变量：'))
ans = m+n
print(f'{m}+{n}={ans}')
print(f'{type(m)} + {type(n)} = {type(ans)')
print(f'{ans:<100.3}')   #整数类型的数据不能加精度.只有浮点可以！

q , e = 0.1 , 0.2
an = q  + e
print(f'q + e ={an:}')
from decimal import Decimal
an2 = Decimal('0.1') + Decimal('0.2')
print(f'q + e = {an2}')
an3 = q/e
print(f'q/e = {an3:^5.2}')

# from decimal import Decimal ; x = Decimal('m') * Decimal('n')

print(chr(0x1f640))
print(chr(97))
print(ord('a'))

from math import sqrt
z = float(input('输入一个数字：'))
ans = sqrt(z)
ans1 = z**5
print(f'ans = {ans:3.2}')
print('%.2f的平方根是：%.2f'%(z,ans))
print('{:2.2f}的平方根是{:2.2f}'.format(z,ans))
print(f'{z:2.2}的平方根是{ans:2.2}')

from  math import  pi
text = '''好奇心是人的天性。

print(text)
R = float(input('给学习画一个大饼，大饼要做的很大，半径要这么大:'))
circle = pi*2*R
print(f'绕起来，大饼的圆周有这么长, {circle:<10.29}, 够不够激发你探索未知的动力...')

running = True
while running:
x = float(input('输入一个整数：'))
y = x ** 365
print(f'{x}的365次方:{y}')

running =True
while running:
from math import pi
from math import log
from math import e
p = 1.038
c = 3.7
K = 0.0054
M = int(input('鸡蛋质量：'))  # 大鸡蛋67  小鸡蛋  47
Tw = 100
T0 = int(input('鸡蛋初始温度：'))  # 冰箱4 常温 20
Ty = 70
t = M ** (2 / 3) * c * p ** (1 / 3) * log(0.76 * (T0 - Tw) / (Ty - Tw)) / (K * pi ** 2 * (4 * pi / 3) ** (2 / 3))
tf = int(t / 60)
tm = round(t - (60 * tf))
print(f'T0 = {T0}℃,t={tf}分{tm}秒')

posted @ 2022-03-23 23:35  奈落——  阅读(27)  评论(2编辑  收藏  举报