实验1

print('hey, u')

print('hey', ' u')
x,y,z = 1,2,3
print(x, y, z)

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

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

 

复制代码
复制代码
x2, y2 = 2.26, 8.7
print('x1 = {}, y1 = {}'.format(x1, y1))
print('x2 = {}, y2 = {}'.format(x2, y2))
print('x1 = {:.1f}, y1 = {:.1f}'.format(x1, y1))
print ('x2 = {:.1f}, y2 = {:.1f}'.format(x2, y2))
print('x1 = {:<15.1f}, y1 = {:<15.1f}'.format(x1, y1))
print('x2 = {:<15.1f}, y2 = {:<15.1f}'.format(x2, y2))
print('x1 = {:>15.1f}, y1 = {:>15.1f}'.format(x1, y1))
print('x2 = {:>15.1f}, y2 = {:>15.1f}'.format(x2, y2))
复制代码
r1 = eval('1 + 2')
r2 = eval('[1, 6, 7.5]')
print(type(r2), r2)
r3 = eval('"python"')
print(type(r3), r3)
r4 = eval('7, 42')
print(type(r4), r4)

 

复制代码
x, y = eval(input('Enter two oprands: '))
ans = x+y
print(f'{x} + {y} = {ans}')
print(f'{type(x)} + {type(y)} = {type(ans)}')

 

复制代码
复制代码
ans1 = 0.1+0.2
print(f'0.1 + 0.2 = {ans1}')
from decimal import Decimal
ans2 = Decimal('0.1') +Decimal('0.2')
print(f'0.1 + 0.2 = {ans2}')

 

复制代码
复制代码
print(chr(0x1f600), end = " ")
print(chr(0x1f601), end = " ")
print(chr(0x1f602), end = " ")
print(chr(0x1f603), end = " ")
print(chr(0x1f604))
print(chr(10000), end=" ")
print(chr(0x025b), end=" ")
print(chr(0x2708), end=" ")
print(chr(0x00A5), end=" ")
print(chr(0x266b))
print(ord('a'), end = " ")
print(ord('b'), end = " ")
print(ord('c'))
print(ord('A'), end = " ")
print(ord('B'), end = " ")
print(ord('C'))
print(ord('0'), end = " ")
print(ord('1'), end = " ")
print(ord('2'))

 

复制代码
复制代码
from math import sqrt
n = float(input('输入一个数:')) ans1 = sqrt(n) ans2 = n**0.5 print('%.2f的平方根是: %.2f'%(n, ans1)) print('{:.2f}的平方根是: {:.2f}'.format(n, ans2)) print(f'{n:.2f}的平方根是: {ans2:.2f}')

 

复制代码
复制代码
from math import pi
text ='''好奇心是人的天性。理想情况下,
学习新东西是让人愉快的事。但学校里的学习似乎有点像苦役。
有时候,需要画一个大饼,每次尝试学一些新鲜的,才会每天变得更好一点点。       '''
print(text)
r = float(input('给学习画一个大饼,大饼要做的很大,半径要这么大: '))
circle = 2*pi*r
print(f'绕起来,大饼的圆周有这么长, {circle}, 够不够激发你探索未知的动力...')

 

复制代码
复制代码
from math import sqrt
x=float(input("输入一个数:"))
ans1=sqrt(x)
ans2=x**365
print('%.2f的365次方是:%.2f'%(x,ans2))

 

复制代码
复制代码
from math import pi,log
k=5.4*10**(-3)
p=1.038
c=3.7
M=67
m=47
Tw=100
Ty=70
T0=eval(input("请输入一个值:"))
T=(pow(M,2/3)*c*pow(p,1/3))/(k*pi*pi*pow(4*pi/3,2/3))*log(0.76*(T0-Tw)/(Ty-Tw))
t=(pow(m,2/3)*c*pow(p,1/3))/(k*pi*pi*pow(4*pi/3,2/3))*log(0.76*(T0-Tw)/(Ty-Tw))
print("{0:0.1f}\t{1:0.1f}".format(T,t))

 

复制代码

 

复制代码

 

复制代码
posted @ 2022-03-28 21:21  东楼贺朝  阅读(9)  评论(3编辑  收藏  举报