返回列表 發帖

資料型態轉換

  1. a=b="20"
  2. print("a="+a)
  3. print("b="+b)
  4. c=a+b
  5. d=int(a)+int(b)
  6. print("字串相加: "+c)
  7. print("數字相加: "+str(d))
複製代碼

  1. a=20
  2. b=23
  3. c=a+b
  4. print("20+23="+str(c))
  5. print(str(a)+str(b))
複製代碼

TOP

  1. a="30"
  2. b="30"
  3. c=int(a)+int(b)
  4. d=a+b
  5. print("數字相加:"+str(c))
  6. print("字串相加:"+str(d))
複製代碼

TOP

  1. A=B=999
  2. print(A+B)
  3. C = str(A)+str(B)
  4. print(C)
  5. print(int(C)+int(A))
  6. D = int(A)+int(B)+int(C)
  7. print(D)
  8. print(A*B*int(C)*int(D))
  9. str(D)
  10. print(D)
複製代碼

TOP

  1. a=20
  2. b=20
  3. c=a+b
  4. d=str(a)+str(b)
  5. print(c)
  6. print(d)
  7. pi=3.141592653589
  8. e=123456
  9. print(int(d)+c)
  10. print(d+str(c))
  11. print(e+pi)
  12. print(int(d)+pi)
  13. print(pi**2)
複製代碼

TOP

a=b="30"
print("a="+a)
print("b="+b)
c=a+b
d=int(a)+int(b)
print("字串相加: "+c)
print("數字相加: "+str(d))

TOP

a="apple"
b="banana"
c=123
pi=3.14159
d=c+pi
dd=str(c)+str(pi)
test1=str(123)
test2=int(test1)
test3=int("567")
print("test")
print(float(dd))
print("test")

TOP

a="apple"
b="banana"
pi=3.14159
c=123
d=c+pi
dd=str(c)+str(pi)
test1=str(123)
test2=int(test1)
test3=int("567")
print("test")
print(float(dd))
print("test")

TOP

a="apple"
b="banana"
c=123
pi=3.1415926
d=c+pi
dd=str(c)+str(pi)
test1=str(123)

TOP

  1. a=b="20"
  2. print("a="+a)
  3. print("b="+b)
  4. c=a+b
  5. d=int(a)+int(b)
  6. print("字串相加: "+c)
  7. print("數字相加: "+str(d))
複製代碼

TOP

本帖最後由 盧承新 於 2023-8-2 13:37 編輯
  1. a=b="20"
  2. c=int(a)+int(b)
  3. print(f"字串相加:{a+b}")
  4. print(f"數字相加:{c}")
複製代碼

TOP

  1. a=b="20"
  2. print("a="+a)
  3. print("b="+b)
  4. c=a+b
  5. d=int(a)+int(b)
  6. print("字串相加:"+c)
  7. print("數字相加:"+str(d))
複製代碼

TOP

  1. a=20
  2. b=20
  3. c=str(a)+str(b)
  4. d=a+b
  5. print("字串相加"+c)
  6. print("數字相加"+str(d))
複製代碼

TOP

  1. a="20"
  2. b="20"
  3. print("a="+a)
  4. print("b="+b)
  5. c=a+b
  6. d=int(a)+int(b)
  7. print("words:",c)
  8. print("numbers:",d)
複製代碼
Attention Seeker </3

TOP

a=10
b=a+5
print(a+b)
a=str(a)
b=str(b)
print(a+b)

TOP

7

TOP

  1. a=z="50"
  2. c=int(a)+int(z)
  3. print(f"字串相加:{a+z}")
  4. print(f"數字相加:{c}")
複製代碼

TOP

  1. x=33
  2. y=33
  3. z=str(x)+str(y)
  4. print(f"數字相加{(x)+(y)}")
  5. print(f"字串相加{z}"
複製代碼

TOP

  1. a="20"
  2. b="20"
  3. print("a="+a)
  4. print("b="+b)
  5. c=a+b
  6. d=int(a)+int(b)
  7. print("字串相加"+c)
  8. print("數字相加"+str(d)
複製代碼

TOP

  1. a="20"
  2. b="20"
  3. c=a+b
  4. d=int(a)+int(b)

  5. print("字串相加: "+c)
  6. print("數字相加: "+str(d))
複製代碼

TOP

返回列表