Python 中乘法使用哪个符号?
Python 计算 8 / 3 的答案是什么?
怎么得到 8 / 3 的余数?
怎么得到 8 / 3 的小数结果?
Python 中计算 6 * 6 * 6 * 6 的另一种做法是什么?
采用 E 记法,17 000 000 要写作什么?
6**4
1296
6*6*6*6
1296
1.7e+7
17000000.0
6*6*6*6
1296
name = input("What is your name?\n")
print("Hi, ", name * 300)
Hi, markmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmarkmark
如果希望得到一个跨多行的字符串,必须使用一种特殊的字符串,称为三重引号字符串(triple-quoted string)
name='sandy'
long_string = '''
碧玉装成一树高,
万条垂下绿丝绦。
不知细叶谁裁出,
二月春风似剪刀。
'''
print(long_string)
碧玉装成一树高,
万条垂下绿丝绦。
不知细叶谁裁出,
二月春风似剪刀。
kimi_room='13301'
print(float(kimi_room))
13301.0
kimi_room='13301'
print(int(kimi_room))
13301
mark_room=15501
mark_room=str(mark_room)
gouwo=mark_room+'1'
print(gouwo)
# print(str(mark_room))
155011
edison_score = 100
edison_score_f = float(edison_score)
print('edison_score=',edison_score,'edison_score_f=',edison_score_f)
edison_score= 100 edison_score_f= 100.0
e=54.99
f=int(e)
print(e,f)
54.99 54
a = '76.3'
b = float(a)
# print(a,b)
type(a)
76.3 76.3
a = '44.2'
b = 44.2
print(type(b))
<class 'float'>
alice = '100'
print (float(alice))
100.0
公式
摄氏度 = 5/9*(华氏度-32) 摄氏度 = (华氏度-32)/1.8
cel = 5.0 / 9 * (fahr - 32)
fahr = 43
cel = (fahr-32)/1.8
print('华氏度=',fahr,'转换成摄氏度=',cel)
华氏度= 43 转换成摄氏度= 6.111111111111111
#在我们的温度转换程序中,可以这样做吗?
cel = float(5 / 9 * (fahr - 32))
cel = 5 / 9 * float(fahr - 32)
print('华氏度=',fahr,'转换成摄氏度=',cel)
华氏度= 43 转换成摄氏度= 6.111111111111112
e=53.9
d=int(e)
print(d)
53
a = 13.2
roundoff = int(a + 0.5)
print(a,roundoff)
b = 13.7
roundoff = int(b + 0.5)
print(b,roundoff)
13.2 13
13.7 14
动手试一试
使用 float() 从一个字符串(如 '12.34')创建一个数。要保证结果确实是一个数!
a = float('12.34')
print (a)
12.34
试着使用 int() 从一个小数(56.78)创建一个整数。答案是上取整还是下取整?
print(int(56.78))
56
试着使用 int() 从一个字符串创建整数。要保证结果确实是一个整数!
a = int('75')
print (a)
75
星际大战5
本文章使用limfx的vscode插件快速发布